Text Input

A versatile text input component supporting multiple types, validation states, and customization options for collecting user text input.

Basic Text Input

Input Types

Required Field

Username is required

With Helper Text

We'll never share your email with anyone else.

Validation States

With Icons (Prefix/Suffix)

Character Count

Must be 20 characters or less

0 / 20

Disabled

Props

NameTypeDefaultDescription
label*string-Input label text
type'text' | 'email' | 'password' | 'number' | 'search' | 'tel' | 'url''text'HTML input type
placeholderstring-Placeholder text
valuestring-Controlled value
defaultValuestring-Uncontrolled default value
disabledbooleanfalseWhether input is disabled
requiredbooleanfalseWhether input is required (shows * indicator)
errorstring-Error message to display
helperTextstring-Helper text below input
showValidIconbooleantrueShow check icon when valid
showErrorIconbooleantrueShow X icon when error
showPasswordTogglebooleantrueShow eye icon for password type
maxLengthnumber-Maximum character length
showCharCountbooleanfalseShow character count (requires maxLength)
leadingIconReactNode-Content before input (icon, text)
trailingIconReactNode-Content after input (icon, text)
onChange(e: ChangeEvent) => void-Change event handler

Usage Guidelines

When to use

  • For collecting single-line text input from users
  • For forms that require specific input types (email, password, phone)
  • When validation feedback needs to be displayed inline
  • For search functionality or filtering data

Best practices

  • Use clear, descriptive labels that tell users what to input
  • Provide helpful placeholder text as examples, not instructions
  • Show validation errors immediately after user interaction
  • Use appropriate input types for better mobile keyboard support
  • Include helper text for complex or important fields
  • Use leading icons to clarify the input purpose (search, email, etc.)

Accessibility

  • Keyboard accessible with Tab, Enter, and Escape keys
  • ARIA attributes: aria-invalid, aria-describedby, aria-required
  • Error messages announced with aria-live regions
  • Focus indicators visible with 2px ring for keyboard navigation
  • Labels properly associated with inputs using htmlFor
  • Required fields indicated with asterisk and aria-required

Do's and Don'ts

Do

  • Use descriptive labels that clearly indicate what input is expected
  • Provide immediate validation feedback after user interaction
  • Use appropriate input types (email, tel, url) for better UX
  • Include helper text for complex requirements or formatting
  • Use leading icons to make the input purpose immediately clear

We'll send a confirmation to this address

Don't

  • Don't use vague labels like "Input" or "Field"
  • Don't use placeholder text as a substitute for labels
  • Don't validate before the user has finished typing
  • Don't use generic error messages like "Invalid input"
  • Don't disable inputs without explanation or alternative

Related Components

Resources