# TextField **Category**: native **URL**: https://www.heroui.com/docs/native/components/text-field **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/text-field.mdx > A text input component with label, description, and error handling for collecting user input. *** ## Import ```tsx import { TextField } from 'heroui-native'; ``` ## Anatomy ```tsx ... ... ``` - **TextField**: Root container that provides spacing and state management - **Label**: Label with optional asterisk for required fields (from [Label](./label) component) - **Input**: Input container with animated border and background (from [Input](./input) component) - **Description**: Secondary descriptive helper text (from [Description](./description) component) - **FieldError**: Validation error message display (from [FieldError](./field-error) component) ## Usage ### Basic Usage TextField provides a complete form input structure with label and description. ```tsx We'll never share your email ``` ### With Required Field Mark fields as required to show an asterisk in the label. ```tsx ``` ### With Validation Display error messages when the field is invalid. ```tsx import { FieldError, Input, Label, TextField } from 'heroui-native'; Please enter a valid email ; ``` ### With Local Invalid State Override Override the context's invalid state for individual components. ```tsx import { Description, FieldError, Input, Label, TextField, } from 'heroui-native'; This shows despite input being invalid Email format is incorrect ; ``` ### Multiline Input Create text areas for longer content. ```tsx Maximum 500 characters ``` ### Disabled State Disable the entire field to prevent interaction. ```tsx ``` ### With Variant Use different variants to style the input based on context. ```tsx ``` ### Custom Styling Customize the input appearance using className. ```tsx ``` ## Example ```tsx import { Ionicons } from '@expo/vector-icons'; import { Description, Input, Label, TextField } from 'heroui-native'; import { useState } from 'react'; import { Pressable, View } from 'react-native'; import { withUniwind } from 'uniwind'; const StyledIonicons = withUniwind(Ionicons); export const TextInputContent = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [isPasswordVisible, setIsPasswordVisible] = useState(false); return ( We'll never share your email with anyone else. setIsPasswordVisible(!isPasswordVisible)} > Password must be at least 6 characters ); }; ``` You can find more examples in the [GitHub repository](). ## API Reference ### TextField | prop | type | default | description | | ------------ | ---------------------------- | ----------- | ----------------------------------------------------------------------------------------- | | children | `React.ReactNode` | - | Content to render inside the text field | | isDisabled | `boolean` | `false` | Whether the entire text field is disabled | | isInvalid | `boolean` | `false` | Whether the text field is in an invalid state | | isRequired | `boolean` | `false` | Whether the text field is required (shows asterisk) | | className | `string` | - | Custom class name for the root element | | animation | `"disable-all" \| undefined` | `undefined` | Animation configuration. Use `"disable-all"` to disable all animations including children | | ...ViewProps | `ViewProps` | - | All standard React Native View props are supported | > **Note**: For Label, Input, Description, and FieldError components, see their respective documentation: > > - [Label documentation](./label) > - [Input documentation](./input) > - [Description documentation](./description) > - [FieldError documentation](./field-error) > > These components automatically consume form state from TextField via the form-item-state context. ## Hooks ### useTextField Hook to access the TextField context values. Must be used within a `TextField` component. ```tsx import { TextField, useTextField } from 'heroui-native'; function CustomComponent() { const { isDisabled, isInvalid, isRequired } = useTextField(); // Use the context values... } ``` #### Returns | property | type | description | | ---------- | --------- | --------------------------------------------- | | isDisabled | `boolean` | Whether the entire text field is disabled | | isInvalid | `boolean` | Whether the text field is in an invalid state | | isRequired | `boolean` | Whether the text field is required |