Field
Groups a label, a control, a description and an error, and links them for assistive technology. Every form control works inside it: Input, Textarea, Select, Checkbox, Switch…
Used to sign in. Never shared.
Set by your admin.
Markdown is supported.
Installation
Or with the shadcn CLI, from the registry:
It installs Label and Input too.
Usage
Size and variant
size and variant on the Field go to the control inside it (Input, Textarea or a Select's trigger), so a form sets its
look once per field rather than on every control. size also scales the label, description, error and the gaps between
them. A control's own size or variant wins over the Field's.
Small and filled, from the Field.
Large and underlined, from the Field.
Validation
Base UI validates the control when it loses focus, from its native constraints (required, type, pattern, min…) or
from validate on the Field. FieldError shows when the field is invalid; match picks the constraint it is for. Pass
invalid to the Field to set it from your own form library instead.
Villages
The gaps follow the page; the label, description and error take the village's type and colours.
Used to sign in. Never shared.
Set by your admin.
Markdown is supported.
Used to sign in. Never shared.
Set by your admin.
Markdown is supported.
Used to sign in. Never shared.
Set by your admin.
Markdown is supported.
Used to sign in. Never shared.
Set by your admin.
Markdown is supported.
Used to sign in. Never shared.
Set by your admin.
Markdown is supported.
Used to sign in. Never shared.
Set by your admin.
Markdown is supported.
Accessibility
FieldLabelnames the control;FieldDescriptionandFieldErrorare linked to it witharia-describedby.- An invalid field sets
aria-invalidon its control, so screen readers announce it. disabledon the Field disables its control and dims its label.
API reference
The parts of Base UI's Field, styled:
| Part | Renders | Notes |
|---|---|---|
Field | <div> | name, disabled, invalid, validate, validationMode; size ("sm" | "default" | "lg") and variant ("default" | "filled" | "underline") for its control |
FieldLabel | <label> | linked to the control |
FieldDescription | <p> | linked with aria-describedby |
FieldError | <div> | match for one constraint; hidden while the field is valid |