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

Sortable data table
PropTypeDefaultDescription
valuestring-Controlled value of the input.
defaultValuestring-Initial value for uncontrolled usage.
placeholderstring"Enter text"Placeholder text shown when the input is empty.
labelstring-Optional visible label displayed with the input.
labelPosition"top" | "left" | "right" | "bottom""top"Controls where the visible label is positioned.
passwordbooleanfalseIf true, renders the input as a password field with a visibility toggle.
readOnlybooleanfalseIf true, the input is read-only.
disabledbooleanfalseDisables the input field.
requiredbooleanfalseMarks the input as required.
autocompletebooleanfalseIf true, enables browser autocomplete.
maxLengthnumber-Maximum number of characters allowed.
outlinebooleanfalseIf true, renders an outlined variant of the input.
iconReact.ComponentType-Optional icon displayed inside the input field.
theme"primary" | "secondary" | "tertiary" | "quaternary" | "clear"Configured DefaultTheme for the input appearance.
rounding"none" | "small" | "medium" | "large"Configured DefaultBorder radius for the input container.
shadow"none" | "light" | "medium" | "strong" | "intense"Configured DefaultShadow style applied to the input container.
state"" | "success" | "error" | "warning"""Validation state appearance for the input.
ariaLabelstring-Accessible label for the input when no visible label is provided.
ariaDescriptionstring-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.
classNamestring-Additional custom class names for the input container.
data-testidstring"text-input"Test ID for the root element.