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

<TextInput
  label="Display Name"
  ariaDescription="Use between 3 and 20 characters."
  placeholder="Choose a display name"
  maxLength={20}
/>

Props

Data table
TypeDescription
aria-activedescendantstringIdentifies the current autocomplete suggestion in custom combobox patterns.
aria-controlsstringIdentifies the element controlled by this input.
aria-describedbystringReferences one or more elements that describe the input.
aria-descriptionstringProvides a short hint to assistive technologies.
aria-disabledbooleanIndicates whether the element is disabled to assistive technologies.
aria-expandedbooleanIndicates whether the input controls an expandable popup.
aria-haspopupboolean | "dialog" | "grid" | "listbox" | "menu" | "tree" | "true" | "false"Indicates whether a popup such as a listbox, grid, or dialog is available.
aria-invalidboolean | "true" | "false" | "grammar" | "spelling"Indicates whether the input has an invalid value.
aria-labelstringExplicit accessible label for the outer field region if needed.
aria-labelledbystringReferences one or more elements that label the input.
aria-readonlybooleanIndicates whether the input is read-only to assistive technologies.
aria-requiredbooleanIndicates whether user input is required.
autocompletebooleanControls whether autocomplete is enabled. Pass true for "on" or false for "off".
classNamestringAdditional CSS class names for custom styling.
data-testidstringOptional test ID for testing frameworks.
iconComponentType<{ className?: string; "aria-hidden"?: boolean; }>Optional icon component displayed beside the input.
labelstringOptional visible label/title for the input.
labelPositionLabelPositionTypePosition of the label. "top" | "left" | "right" | "bottom"
maxLengthnumberMaximum length of the input.
onChange((value: string, event: React.ChangeEvent<HTMLInputElement>) => void)Called when the input value changes. Returns both the current value and the original change event.
outlinebooleanIf true, the input is outlined instead of filled.
passwordbooleanIf true, the input behaves as a password field and shows a visibility toggle.
readOnlybooleanIf true, the input is rendered in read-only mode.
roleReact.AriaRoleDeclares the role when this input is used in advanced patterns such as searchbox, combobox, or spinbutton.
roundingRoundingTypeRounding of the component. "none" | "small" | "medium" | "large" | "full"
shadowShadowTypeShadow of the component. "none" | "light" | "medium" | "strong" | "intense"
srOnlyTextReactNodeOptional content rendered for assistive technologies only. Useful for dynamic status or extra context.
stateStateTypeState of the input. "success" | "error" | "warning" | "disabled" | ""
themeThemeTypeTheme used for styling. "primary" | "secondary" | "tertiary" | "quaternary" | "clear"