TextInput
A flexible text input component with support for labels, validation, and various states.
Basic Usage
Basic Text Input
import { TextInput } from 'fluxo-ui';
function MyComponent() {
const [value, setValue] = useState('');
return (
<TextInput
placeholder="Enter some text..."
value={value}
onChange={(e) => setValue(e.target.value)}
/>
);
}With Label
Text Input with Label
<TextInput
label="Full Name"
placeholder="John Doe"
/>With Icons
Text Input with Icons
<TextInput
label="Search"
placeholder="Search..."
rightIcon={<span>🔍</span>}
value={value}
onChange={(e) => setValue(e.value)}
/>
<TextInput
label="Email"
placeholder="user@example.com"
leftIcon={<span>✉</span>}
value={value}
onChange={(e) => setValue(e.value)}
/>States
Input States
<TextInput label="Normal" placeholder="Normal state" value={value} onChange={(e) => setValue(e.value)} />
<TextInput label="Disabled" placeholder="Disabled state" value={value} onChange={(e) => setValue(e.value)} disabled />
<TextInput label="Read Only" value="Read only value" readonly onChange={(e) => setValue(e.value)} />
<TextInput label="Required" placeholder="Required field" value={value} onChange={(e) => setValue(e.value)} required />Validation
Input with Validation
const [value, setValue] = useState('');
const [error, setError] = useState('');
const handleChange = (e) => {
const newValue = e.target.value;
setValue(newValue);
if (newValue.length < 3 && newValue.length > 0) {
setError('Must be at least 3 characters');
} else {
setError('');
}
};
<TextInput
label="Username"
placeholder="Enter username"
value={value}
onChange={handleChange}
error={error}
/>Import
import { TextInput } from 'fluxo-ui';Props
valuestringCurrent value of the input (controlled)
valuestringCurrent value of the input (controlled)
placeholderstringPlaceholder text
placeholderstringPlaceholder text
labelstringLabel text
labelstringLabel text
errorstring | booleanError message string (also marks field invalid). Pass `true` to mark invalid without a message
errorstring | booleanError message string (also marks field invalid). Pass `true` to mark invalid without a message
invalidbooleanForce the field into an invalid state without an error message
invalidbooleanForce the field into an invalid state without an error message
helperTextReactNodeHelper text rendered under the input and linked via aria-describedby
helperTextReactNodeHelper text rendered under the input and linked via aria-describedby
clearableboolean"false"Show an X button to clear the input value
clearableboolean"false"Show an X button to clear the input value
onClear() => voidCallback fired after the value is cleared via the clear button
onClear() => voidCallback fired after the value is cleared via the clear button
disabledbooleanfalseDisable the input
disabledbooleanfalseDisable the input
readonlybooleanfalseMake the input read-only
readonlybooleanfalseMake the input read-only
requiredbooleanfalseMark the input as required
requiredbooleanfalseMark the input as required
autoFocusbooleanfalseAuto focus the input on mount
autoFocusbooleanfalseAuto focus the input on mount
maxLengthnumberMaximum character limit
maxLengthnumberMaximum character limit
minLengthnumberMinimum character requirement
minLengthnumberMinimum character requirement
patternstringRegex pattern for validation
patternstringRegex pattern for validation
autoCompletestringAuto-complete hint
autoCompletestringAuto-complete hint
leftIconReactNodeIcon to display on the left side
leftIconReactNodeIcon to display on the left side
rightIconReactNodeIcon to display on the right side
rightIconReactNodeIcon to display on the right side
idstringUnique identifier for the input
idstringUnique identifier for the input
namestringName attribute for the input
namestringName attribute for the input
onChangefunctionChange event handler
onChangefunctionChange event handler
classNamestringAdditional CSS classes
classNamestringAdditional CSS classes
Features
Controlled Input
Fully controlled via value and onChange for form state management
Icon Slots
Left and right icon slots accept any React node
Validation
Error prop displays inline validation messages below the input
States
Disabled, read-only, required, and error states fully supported
Character Limits
maxLength and minLength props for length constraints
Accessibility
Label association, ARIA attributes, and keyboard focus support
Theming
Full dark/light + 5 brand themes via CSS variables — zero extra config