- Docs
- Components
- Field
Field
Combine labels, controls, and help text to compose accessible form fields.
Installation
Anatomy
Structure
<Field.Root>is the core wrapper for a single field.<Field.Content>is a flex column that groups label and description. Not required if you have no description.- Wrap related fields with
<Field.Group>, and use<Field.Set>with<Field.Legend>for semantic grouping.
Form
See the Forms documentation for building forms with the Field component and TanStack Form or React Hook Form.
Examples
Input
Use <Field.Root> with the render prop to compose with <TextField> for automatic accessibility wiring.
Without TextField
You can use <Field.Root> with <Input> directly, but you must provide htmlFor on the label and id on the input manually.
Without TextField, you lose React Aria's automatic ID association for label,
description, and error elements. Use <TextField> when accessibility is
critical.
Textarea
Select
Checkbox
Radio Group
Switch
Fieldset
Use <Field.Set> and <Field.Legend> for semantic grouping of related fields.
Field Group
Stack <Field.Root> components with <Field.Group>. Add <Field.Separator> to divide them.
Responsive Layout
- Vertical fields: Default orientation stacks label, control, and helper text—ideal for mobile-first layouts.
- Horizontal fields: Set
orientation="horizontal"on<Field.Root>to align the label and control side-by-side. Pair with<Field.Content>to keep descriptions aligned. - Responsive fields: Set
orientation="responsive"for automatic column layouts inside container-aware parents.
Validation and Errors
When using <Field.Root> with React Aria field components like <TextField>, <NumberField>, <DateField>, <ColorField>, or <Select>, pass isInvalid to the field component—it handles the invalid state automatically:
If you're not using React Aria field components, you must handle validation state manually:
- Add
data-invalidto<Field.Root>to switch the entire block into an error state. - Add
aria-invalidon the input itself for assistive technologies. - Render
<Field.Error>immediately after the control or inside<Field.Content>to keep error messages aligned with the field.
Accessibility
<Field.Set>and<Field.Legend>keep related controls grouped for keyboard and assistive tech users.<Field.Root>outputsrole="group"so nested controls inherit labeling from<Field.Label>and<Field.Legend>when combined.- When using
<Field.Root>withrender={<TextField />}, React Aria automatically associates label, description, and error elements viaaria-labelledbyandaria-describedby.
API Reference
Field.Set
Container that renders a semantic fieldset with spacing presets.
| Prop | Type | Default |
|---|---|---|
className | string |
Field.Legend
Legend element for a <Field.Set>. Switch to the label variant to align with label sizing.
| Prop | Type | Default |
|---|---|---|
variant | "legend" | "label" | "legend" |
className | string |
Field.Group
Layout wrapper that stacks <Field.Root> components and enables container queries for responsive orientations.
| Prop | Type | Default |
|---|---|---|
className | string |
Field.Root
The core wrapper for a single field. Provides orientation control, invalid state styling, and spacing.
| Prop | Type | Default |
|---|---|---|
orientation | "vertical" | "horizontal" | "responsive" | "vertical" |
render | React.ReactElement | |
className | string | |
data-invalid | boolean |
Use the render prop to compose with React Aria components like <TextField>:
Field.Content
Flex column that groups control and descriptions when the label sits beside the control.
| Prop | Type | Default |
|---|---|---|
className | string |
Field.Label
Label styled for both direct inputs and nested Field.Root children.
| Prop | Type | Default |
|---|---|---|
className | string | |
htmlFor | string |
Field.Title
Renders a title with label styling inside <Field.Content>.
| Prop | Type | Default |
|---|---|---|
className | string |
Field.Description
Helper text slot. Uses React Aria's <Text> component with slot="description".
| Prop | Type | Default |
|---|---|---|
className | string |
Field.Separator
Visual divider to separate sections inside a <Field.Group>. Accepts optional inline content.
| Prop | Type | Default |
|---|---|---|
className | string |
Field.Error
Accessible error container that accepts children or an errors array.
| Prop | Type | Default |
|---|---|---|
errors | Array<{ message?: string } | undefined> | |
className | string |
When the errors array contains multiple messages, the component renders a list automatically.
On This Page
- Installation
- Anatomy
- Structure
- Form
- Examples
- Input
- Without TextField
- Textarea
- Select
- Checkbox
- Radio Group
- Switch
- Fieldset
- Field Group
- Responsive Layout
- Validation and Errors
- Accessibility
- API Reference
- Field.Set
- Field.Legend
- Field.Group
- Field.Root
- Field.Content
- Field.Label
- Field.Title
- Field.Description
- Field.Separator
- Field.Error