Overview
TextField is a form input component that allows users to enter single-line text. It supports various input types, validation states, adornments (prefix/suffix elements), and multiple size variants.Basic Usage
With Validation
With Adornments
- Left Adornment
- Right Adornment
- Both Sides
Sizes
TextField comes in four sizes:small, medium (default), large, and extra-large.
Input Types
Props
The name of the input field. Used for form submission and identification.
The label displayed above the input field.
Placeholder text displayed when the field is empty.
The current value of the input field.
The HTML input type. Accepts any valid HTML input type (text, email, password, number, url, tel, etc.).
Hint for mobile keyboards. Options:
'none' | 'text' | 'search' | 'email' | 'tel' | 'url' | 'numeric' | 'decimal'The size of the input field. Options:
'small' | 'medium' | 'large' | 'extra-large'The color theme for the field. Options:
'brand' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info'Whether the field is required. Displays a required indicator next to the label.
Whether the input field is disabled.
Whether the input field is read-only.
Error message to display when the field is invalid.
Helper text displayed below the input field.
Maximum number of characters allowed. Shows character count when combined with helpMessage.
Minimum value for number inputs.
Maximum value for number inputs.
Step value for number inputs.
Regular expression pattern for validation.
HTML autocomplete attribute.
Whether the field should autofocus on mount.
Adornments to display inside the input field.Properties:
start: React node displayed at the start (left) of the inputend: React node displayed at the end (right) of the input
Callback fired when the input value changes.
Callback fired when the input loses focus.
Callback fired when the input receives focus.
Callback fired when the input is clicked.
Callback fired when a key is pressed.
Additional CSS class name for the container.
TypeScript
Accessibility
- The component uses semantic HTML with proper
<label>and<input>elements - Required fields are indicated with
aria-required - Error messages are announced to screen readers
- All interactive elements are keyboard accessible
When using adornments with interactive elements (buttons, icons), ensure they are keyboard accessible and have appropriate ARIA labels.