Field

Labels, descriptions and errors for form controls.

Profile

Shown to other members of your team.

Use the name people know you by.

Installation

  1. Add the registryOnce per project
  2. Add field

Usage

FieldSet groups related fields under a FieldLegend, and FieldGroup stacks them. Each Field holds one control with its label, description and error. FieldContent keeps a label and description together beside a control.

A Field links its parts to the control inside it, so the label names it and screen readers read the description and error with it, without any ids. Every control built on Base UI takes part, as do Textarea and NativeSelect. For the rest, such as DatePicker, point the FieldLabel at the control's id with htmlFor.

Outside a Field, FieldLabel is a plain label. Wrap a checkbox, radio or switch in it to label that control, or point it at one with htmlFor. An icon before its text is sized and dimmed to match.

In a Form, give each Field a name. The form submits the control's value under that name and validates it, and FieldError shows what went wrong.

Composition

Examples

Invalid

Set invalid on the field, which marks the control invalid too, and put the message in FieldError. It also takes an errors array of { message } objects, as form libraries return. Without either, FieldError shows the message from the field's own validation whenever it fails.

Disabled

Set disabled on the field to disable its control and fade the label and description with it.

Managed by your organization.

Horizontal

orientation="horizontal" puts the control and label in a row, in the order you write them.

A summary of activity every Monday.

News about features and improvements.

Radio group

Wrap each option of a radio or checkbox group in a FieldItem, which links its label and description to it. variant="label" makes a FieldLegend look like a label instead of a heading.

Send notifications to

With a separator

FieldSeparator is a Separator spaced to sit between fields. Children put a label in the middle of it.

Choice cards

Put a control and its FieldContent inside a FieldLabel to make the whole card clickable. Use FieldTitle for its title, since a label can't contain another label.

Responsive

orientation="responsive" stacks the label and control until the FieldGroup is wide enough to put them side by side.

Used for emails and the interface.

Props

Field has the group role, and FieldError the alert role. FieldError's match picks the failed check it shows for, as the Form page explains.

The tables leave out className, style and render. Parts built on Base UI take them as its styling and composition guides describe.

FieldLegend

Field

FieldItem

FieldLabel

FieldSeparator

FieldError