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 & Examples

Default

default.tsx
const [value, setValue] = useState("");
  
  <TextInput
    value={value}
    onChange={(nextValue) => setValue(nextValue)}
    placeholder="Enter text..."
  />

With Label

with-label.tsx
const [value, setValue] = useState("");
  
  <TextInput
    label="Username"
    labelPosition="top"
    value={value}
    onChange={(nextValue) => setValue(nextValue)}
    placeholder="Enter your username"
  />

With Icon

with-icon.tsx
const [value, setValue] = useState("");
  
  <TextInput
    icon={FaUser}
    value={value}
    onChange={(nextValue) => setValue(nextValue)}
    placeholder="Username"
  />

Password Input

password-input.tsx
const [value, setValue] = useState("");
  
  <TextInput
    password
    icon={FaLock}
    value={value}
    onChange={(nextValue) => setValue(nextValue)}
    placeholder="Enter password"
  />

Validation States

validation-states.tsx
<TextInput state="success" defaultValue="Valid value" />
  <TextInput state="warning" defaultValue="Needs review" />
  <TextInput state="error" defaultValue="Invalid value" />

Outlined Input

outlined-input.tsx
const [value, setValue] = useState("");
  
  <TextInput
    variant="outline"
    label="Email"
    icon={FaEnvelope}
    value={value}
    onChange={(nextValue) => setValue(nextValue)}
    placeholder="Enter your email"
  />

With Accessible Description

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

Props API

45 props
Columns
Text Input props API
Default
Description
aria-activedescendantstringNoariaIdentifies the current autocomplete suggestion in custom combobox patterns.
aria-controlsstringNoariaIdentifies the element controlled by this input.
aria-describedbystringNoariaReferences one or more elements that describe the input.
aria-descriptionstringNoariaProvides a short hint to assistive technologies.
aria-disabledbooleanNoariaIndicates whether the element is disabled to assistive technologies.
aria-expandedbooleanNoariaIndicates whether the input controls an expandable popup.
aria-haspopupboolean | "dialog" | "grid" | "listbox" | "menu" | "tree" | "true" | "false"NoariaIndicates whether a popup such as a listbox, grid, or dialog is available.
aria-invalidboolean | "true" | "false" | "grammar" | "spelling"NoariaIndicates whether the input has an invalid value.
aria-labelstringNoariaExplicit accessible label for the outer field region if needed.
aria-labelledbystringNoariaReferences one or more elements that label the input.
aria-readonlybooleanNoariaIndicates whether the input is read-only to assistive technologies.
aria-requiredbooleanNoariaIndicates whether user input is required.