TextInput
TextInput allows users to enter and edit text content in a single line.
Installation
Usage
Props
TextInput
Extends React Native's TextInput props.
Prop | Type | Default | Description |
---|---|---|---|
label | string | - | Label text displayed above the input. |
helperText | string | 'Helper text' | Helper text displayed below the label. |
errorMessage | string | - | Error message displayed when state is 'error'. |
required | boolean | true | When true, displays required indicator (*). |
variant | 'default' | 'prefix' | 'suffix' | 'default' | The visual variant of the input. |
state | 'default' | 'focus' | 'error' | 'success' | 'disabled' | 'default' | The current state of the input. |
prefix | ReactNode | - | Element displayed before the input text. |
suffix | string | - | Text displayed after the input text. |
Examples
Default Input
With Prefix Icon
With Suffix Text
Error State
Success State
Disabled State
Styling
The TextInput component uses Tailwind CSS classes for styling through class-variance-authority (cva). Default styling includes:
- Container width: 329px
- Height: 40px
- Base text size with 24px line height
- White background
- Base ink text color
- Gray placeholder color
- Font family: Source Sans Pro
- Consistent padding based on variant
- Border styling for different states
States
The input has several visual states:
- Default: Base ink border
- Focus: 4px focus ring border
- Error: 4px error dark border with left indicator
- Success: 4px success border
- Disabled: Light background with reduced opacity
Accessibility
The TextInput component:
- Uses semantic text input structure
- Provides clear labeling
- Supports screen readers with
accessibilityRole
andaccessibilityLabel
- Maintains proper text contrast
- Includes helper text for additional context
- Shows error states clearly
- Supports keyboard navigation
- Indicates required fields