Input
A customizable text input component with multiple style variants, error handling, and icon support.
Input
The Input component is a versatile text input field with multiple style variants, error handling, and support for right icons. It enhances the standard React Native TextInput with additional features and styling to create a cohesive and user-friendly form experience.
Features
- Multiple Variants: Choose from three style variants:
- animated: Floating label that animates from placeholder to top position
- classic: Traditional input with label positioned above
- underlined: Minimalist input with only a bottom border
 
- Error Handling: Displays error messages with distinct styling
- Password Support: Toggle visibility option for password fields
- Right Icon: Optional icon on the right side with customizable press behavior
- Multiline Support: Can be used for both single-line and multiline text input
- Dark Mode Support: Automatic light/dark mode styles
Import
Props
| Prop | Type | Default | Description | 
|---|---|---|---|
| value | string | — | The current value of the input | 
| onChangeText | (text: string) => void | — | Function called when the text changes | 
| label | string | — | Text label for the input field | 
| error | string | — | Error message to display below the input | 
| variant | 'animated' | 'classic' | 'underlined' | 'animated' | Style variant of the input | 
| isPassword | boolean | false | If true, treats the input as a password field with visibility toggle | 
| rightIcon | IconName | — | Icon to display on the right side of the input | 
| onRightIconPress | () => void | — | Function called when the right icon is pressed | 
| isMultiline | boolean | false | If true, enables multiline input mode | 
| className | string | '' | Additional Tailwind classes for the input | 
| containerClassName | string | '' | Additional Tailwind classes for the container | 
| ...TextInputProps | — | — | All standard React Native TextInput props are supported | 
Usage Examples
Input Variants
Input with Error and Password
Input with Icon
Form Example
Here's a simplified form example using different input variants:
Best Practices
- 
Choose the right variant for your use case: - Use animatedfor forms where you want to save space while maintaining clarity
- Use classicfor traditional forms with simple, predictable behavior
- Use underlinedfor a modern, minimal aesthetic or when you want to reduce visual noise
 
- Use 
- 
Use appropriate keyboard types for different inputs (email-address, numeric, phone-pad) 
- 
Provide clear error messages that help users understand how to correct their input 
- 
Match variant to context: For example, use the underlined variant for search functionality or within cards, and the classic variant for more complex forms 
Variant Comparison
| Variant | Description | Best Used For | 
|---|---|---|
| animated | Default floating label that animates to the top when focused | Standard forms, registration flows | 
| classic | Traditional input with label fixed above the field | Complex forms, when clarity is priority | 
| underlined | Minimalist input with only a bottom border | Search fields, clean designs, in-line editing | 
Implementation Details
The Input component uses React Native's TextInput, View, and Animated components to create a polished input experience. The floating label is implemented using an animated value that transitions based on focus state and input value.
For password inputs, the component automatically adds a toggle icon to show/hide the password text.
The component uses the useThemeColors hook to apply appropriate color schemes for both light and dark modes.
Notes
- The floating label animation occurs when the input is focused or has a value
- The input border color changes based on focus state and error state
- For password fields, a visibility toggle icon is automatically added
- The component supports all standard TextInput props like placeholder,keyboardType, etc.
- The input height adjusts automatically when in multiline mode
- Clicking on the label will focus the input field