Text Input
The Text Input component supports single-line text entry with theming, validation states, icons, labels, password visibility toggling, and accessibility features for flexible input handling.
Usage
Default
const [value, setValue] = useState("");
<TextInput
value={value}
onChange={(nextValue) => setValue(nextValue)}
placeholder="Enter text..."
/>With Label
const [value, setValue] = useState("");
<TextInput
label="Username"
labelPosition="top"
value={value}
onChange={(nextValue) => setValue(nextValue)}
placeholder="Enter your username"
/>With Icon
const [value, setValue] = useState("");
<TextInput
icon={FaUser}
value={value}
onChange={(nextValue) => setValue(nextValue)}
placeholder="Username"
/>Password Input
const [value, setValue] = useState("");
<TextInput
password
icon={FaLock}
value={value}
onChange={(nextValue) => setValue(nextValue)}
placeholder="Enter password"
/>Validation States
<TextInput state="success" defaultValue="Valid value" />
<TextInput state="warning" defaultValue="Needs review" />
<TextInput state="error" defaultValue="Invalid value" />Outlined Input
const [value, setValue] = useState("");
<TextInput
outline
label="Email"
icon={FaEnvelope}
value={value}
onChange={(nextValue) => setValue(nextValue)}
placeholder="Enter your email"
/>With Accessible Description
Use between 3 and 20 characters.
<TextInput
label="Display Name"
ariaDescription="Use between 3 and 20 characters."
placeholder="Choose a display name"
maxLength={20}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Controlled value of the input. |
| defaultValue | string | - | Initial value for uncontrolled usage. |
| placeholder | string | "Enter text" | Placeholder text shown when the input is empty. |
| label | string | - | Optional visible label displayed with the input. |
| labelPosition | "top" | "left" | "right" | "bottom" | "top" | Controls where the visible label is positioned. |
| password | boolean | false | If true, renders the input as a password field with a visibility toggle. |
| readOnly | boolean | false | If true, the input is read-only. |
| disabled | boolean | false | Disables the input field. |
| required | boolean | false | Marks the input as required. |
| autocomplete | boolean | false | If true, enables browser autocomplete. |
| maxLength | number | - | Maximum number of characters allowed. |
| outline | boolean | false | If true, renders an outlined variant of the input. |
| icon | React.ComponentType | - | Optional icon displayed inside the input field. |
| theme | "primary" | "secondary" | "tertiary" | "quaternary" | "clear" | Configured Default | Theme for the input appearance. |
| rounding | "none" | "small" | "medium" | "large" | Configured Default | Border radius for the input container. |
| shadow | "none" | "light" | "medium" | "strong" | "intense" | Configured Default | Shadow style applied to the input container. |
| state | "" | "success" | "error" | "warning" | "" | Validation state appearance for the input. |
| ariaLabel | string | - | Accessible label for the input when no visible label is provided. |
| ariaDescription | string | - | Additional description announced to screen readers using aria-describedby. |
| onChange | (value: string, event: React.ChangeEvent<HTMLInputElement>) => void | - | Called when the input value changes. Receives both the current value and the original change event. |
| className | string | - | Additional custom class names for the input container. |
| data-testid | string | "text-input" | Test ID for the root element. |