1. Docs
  2. Components
  3. 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.

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-invalid to <Field.Root> to switch the entire block into an error state.
  • Add aria-invalid on 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> outputs role="group" so nested controls inherit labeling from <Field.Label> and <Field.Legend> when combined.
  • When using <Field.Root> with render={<TextField />}, React Aria automatically associates label, description, and error elements via aria-labelledby and aria-describedby.

API Reference

Field.Set

Container that renders a semantic fieldset with spacing presets.

PropTypeDefault
classNamestring

Field.Legend

Legend element for a <Field.Set>. Switch to the label variant to align with label sizing.

PropTypeDefault
variant"legend" | "label""legend"
classNamestring

Field.Group

Layout wrapper that stacks <Field.Root> components and enables container queries for responsive orientations.

PropTypeDefault
classNamestring

Field.Root

The core wrapper for a single field. Provides orientation control, invalid state styling, and spacing.

PropTypeDefault
orientation"vertical" | "horizontal" | "responsive""vertical"
renderReact.ReactElement
classNamestring
data-invalidboolean

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.

PropTypeDefault
classNamestring

Field.Label

Label styled for both direct inputs and nested Field.Root children.

PropTypeDefault
classNamestring
htmlForstring

Field.Title

Renders a title with label styling inside <Field.Content>.

PropTypeDefault
classNamestring

Field.Description

Helper text slot. Uses React Aria's <Text> component with slot="description".

PropTypeDefault
classNamestring

Field.Separator

Visual divider to separate sections inside a <Field.Group>. Accepts optional inline content.

PropTypeDefault
classNamestring

Field.Error

Accessible error container that accepts children or an errors array.

PropTypeDefault
errorsArray<{ message?: string } | undefined>
classNamestring

When the errors array contains multiple messages, the component renders a list automatically.