--- title: Field description: "`Field` is a component used to group form elements with label, helper message, error message, etc." links: - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/field - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-field--basic --- ```tsx ``` ## Usage ```tsx import { Field } from "@yamada-ui/react" ``` ```tsx import { Field } from "@/components/ui" ``` ```tsx import { Field } from "@workspaces/ui" ``` ```tsx ``` ### Displaying a Helper Message To display a helper message, set a `ReactNode` to `helperMessage`. ```tsx ``` Alternatively, you can customize using `Field.HelperMessage`. ```tsx We'll never share your email. ``` ### Displaying an Error Message To display an error message, set `invalid` to `true` and assign a `ReactNode` to `errorMessage`. ```tsx ``` Alternatively, you can customize using `Field.ErrorMessage`. ```tsx Email is required. ``` ### Replacing Helper and Error Messages Error messages are only displayed when `invalid` is `true`. To replace the helper message with the error message when the error message is displayed, set `replace` to `true`. By default, it is set to `true`. ```tsx ``` ### Required To make it required, set `required` to `true`. ```tsx ``` ### Disable To disable, set `disabled` to `true`. ```tsx ``` ### Read-Only To make it read-only, set `readOnly` to `true`. ```tsx ``` ### Change Direction To change the direction, set `orientation` to `"horizontal"` or `"vertical"`. By default, `"vertical"` is set. ```tsx {(orientation, index) => ( )} ``` ### Customize the Label To customize the label, use `Field.Label`. ```tsx Email address ``` ### Customize the Required Indicator To customize the required indicator, set a `ReactNode` to `requiredIndicator`. ```tsx required } > required } > Email address ``` ### Use Optional Indicator To use an optional indicator, set a `ReactNode` to `optionalIndicator`. ```tsx optional} > optional}> Email address ``` ## Uses Components & Hooks ## Used By Components & Hooks ## Props ## Accessibility ### ARIA Roles and Attributes | Component | Roles and Attributes | Usage | | ------------------------ | --------------------- | -------------------------------------------------- | | `FieldRequiredIndicator` | `role="presentation"` | Indicates that this is a presentation element. | | | `aria-hidden` | Excludes the element from the accessibility tree. | | `Field.ErrorMessage` | `aria-live="polite"` | Indicates that it may be updated outside of focus. |