# ControlField **Category**: native **URL**: https://www.heroui.com/docs/native/components/control-field **Source**: https://raw.githubusercontent.com/heroui-inc/heroui/refs/heads/v3/apps/docs/content/docs/native/components/(forms)/control-field.mdx > A field component that combines a label, description (or other content), and a control component (Switch or Checkbox) into a single pressable area. *** ## Import ```tsx import { ControlField } from 'heroui-native'; ``` ## Anatomy ```tsx ... ... ... ``` - **ControlField**: Root container that manages layout and state propagation - **Label**: Primary text label for the control (from [Label](./label) component) - **Description**: Secondary descriptive helper text (from [Description](./description) component) - **ControlField.Indicator**: Container for the form control component ([Switch](./switch), [Checkbox](./checkbox), [Radio](./radio)) - **FieldError**: Validation error message display (from [FieldError](./field-error) component) ## Usage ### Basic Usage ControlField wraps form controls to provide consistent layout and state management. ```tsx ``` ### With Description Add helper text below the label using the Description component. ```tsx Receive push notifications about your account activity ``` ### With Error Message Display validation errors using the ErrorMessage component. ```tsx By checking this box, you agree to our Terms of Service This field is required ``` ### Disabled State Control interactivity with the disabled prop. ```tsx This field is disabled ``` ### Disabling All Animations Disable all animations including children by using `"disable-all"`. This cascades down to all child components. ```tsx Description text ``` ## Example ```tsx import { Checkbox, Description, FieldError, ControlField, Label, Switch, } from 'heroui-native'; import React from 'react'; import { ScrollView, View } from 'react-native'; export default function ControlFieldExample() { const [notifications, setNotifications] = React.useState(false); const [terms, setTerms] = React.useState(false); const [newsletter, setNewsletter] = React.useState(true); return ( Receive push notifications about your account activity By checking this box, you agree to our Terms of Service This field is required ); } ``` You can find more examples in the [GitHub repository](https://github.com/heroui-inc/heroui-native/blob/main/example/src/app/(home)/components/control-field.tsx). ## API Reference ### ControlField | prop | type | default | description | | ----------------- | -------------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------- | | children | `React.ReactNode \| ((props: ControlFieldRenderProps) => React.ReactNode)` | - | Content to render inside the form control, or a render function | | isSelected | `boolean` | `undefined` | Whether the control is selected/checked | | isDisabled | `boolean` | `false` | Whether the form control is disabled | | isInvalid | `boolean` | `false` | Whether the form control is invalid | | isRequired | `boolean` | `false` | Whether the form control is required | | className | `string` | - | Custom class name for the root element | | onSelectedChange | `(isSelected: boolean) => void` | - | Callback when selection state changes | | animation | `"disable-all" \| undefined` | `undefined` | Animation configuration. Use `"disable-all"` to disable all animations including children | | ...PressableProps | `PressableProps` | - | All React Native Pressable props are supported | ### Label The `Label` component automatically consumes form state (`isDisabled`, `isInvalid`) from the ControlField context. **Note**: For complete prop documentation, see the [Label component documentation](./label). ### Description The `Description` component automatically consumes form state (`isDisabled`, `isInvalid`) from the ControlField context. **Note**: For complete prop documentation, see the [Description component documentation](./description). ### ControlField.Indicator | prop | type | default | description | | ------------ | ----------------------------------- | ---------- | ---------------------------------------------------------- | | children | `React.ReactNode` | - | Control component to render (Switch, Checkbox, Radio) | | variant | `'checkbox' \| 'radio' \| 'switch'` | `'switch'` | Variant of the control to render when no children provided | | className | `string` | - | Custom class name for the indicator element | | ...ViewProps | `ViewProps` | - | All React Native View props are supported | **Note**: When children are provided, the component automatically passes down `isSelected`, `onSelectedChange`, `isDisabled`, and `isInvalid` props from the ControlField context if they are not already present on the child component. When using the `radio` variant, the Radio component renders in standalone mode (outside of a RadioGroup). ### FieldError The `FieldError` component automatically consumes form state (`isInvalid`) from the ControlField context. **Note**: For complete prop documentation, see the [FieldError component documentation](./field-error). The error message visibility is controlled by the `isInvalid` state of the parent ControlField. ## Hooks ### useControlField **Returns:** | property | type | description | | ------------------ | ---------------------------------------------- | ---------------------------------------------- | | `isSelected` | `boolean \| undefined` | Whether the control is selected/checked | | `onSelectedChange` | `((isSelected: boolean) => void) \| undefined` | Callback when selection state changes | | `isDisabled` | `boolean` | Whether the form control is disabled | | `isInvalid` | `boolean` | Whether the form control is invalid | | `isPressed` | `SharedValue` | Reanimated shared value indicating press state |