Basel Standard / Docs
Field
Layout and messaging primitive for labels, helper text, validation, and grouped form rhythm.
Use the published collection name so exports, permissions, and invoice labels stay aligned.
Field handles the structure around an input rather than the input itself. It gives labels, descriptions, legends, separators, and errors one consistent rhythm so forms stay legible when density increases or validation appears.
Installation
Purchase access, then open /account/install to issue a registry token.Usage
import {
Field,
FieldContent,
FieldDescription,
FieldError,
FieldLabel,
} from "@/components/ui/field"
<Field>
<FieldLabel htmlFor="slug">Archive slug</FieldLabel>
<FieldContent>
<Input id="slug" />
<FieldDescription>Used in the public URL.</FieldDescription>
<FieldError>Enter a unique slug.</FieldError>
</FieldContent>
</Field>
Why This Primitive Exists
Most forms fail at the surrounding structure, not the input itself. The field primitive standardizes that structure so the label column, helper copy, and error treatment remain composed across simple forms and denser settings panels.
- Use it when labels and supporting text need a stable relationship to the control.
- Use
FieldSet,FieldLegend, andFieldSeparatorto break large forms into readable groups. - Avoid it when a component already owns its full layout and validation contract, such as the
Formhelper layer.
Examples
Basic Vertical Field
The default vertical layout is the right starting point for ordinary forms and modal tasks.
Use the published collection name so exports, permissions, and invoice labels stay aligned.
<Field>
<FieldLabel htmlFor="name">Collection name</FieldLabel>
<FieldContent>
<Input id="name" />
<FieldDescription>Use the published collection name.</FieldDescription>
</FieldContent>
</Field>
Horizontal And Responsive Layouts
Orientation controls how the label and content share space. Use horizontal layouts when the page has enough width to support a scanning label column.
Horizontal fields work well in settings panels where labels need to scan in a stable left column.
The responsive layout keeps a stacked rhythm on smaller widths and shifts to a two-column frame when space allows.
<Field orientation="horizontal">
<FieldLabel htmlFor="owner">Approval owner</FieldLabel>
<FieldContent>
<Input id="owner" />
</FieldContent>
</Field>
In Context
The full field family becomes more valuable when a settings card needs legends, separators, titles, and inline validation without custom spacing logic.
Settings panel
<FieldSet>
<FieldLegend>Release settings</FieldLegend>
<Field orientation="horizontal" data-invalid="true">
<FieldLabel htmlFor="owner">Owner email</FieldLabel>
<FieldContent>
<Input id="owner" aria-invalid />
<FieldError>Enter a complete address.</FieldError>
</FieldContent>
</Field>
</FieldSet>
Guidance
Use Field For Layout, Not State
Fielddoes not manage form state or ids for you.- Use it with plain inputs when you want structural consistency without a form library.
- Pair it with
Formwhen the control needs automatic accessibility wiring from validation state.
Choose Orientation By Density
- Use
verticalfor dialogs, drawers, and shorter forms. - Use
horizontalwhen the page has room for a left label column. - Use
responsivewhen the same form should stack on small screens and align in columns on larger ones.
Treat Supporting Copy As Part Of The Form
- Use
FieldDescriptionto explain constraints before the user hits an error. - Use
FieldErrorfor actionable problems, not long explanations. - Group related settings with
FieldSet,FieldLegend, andFieldSeparatorinstead of inserting ad hoc spacers.
API Reference
Core Exports
| Export | Renders | Notes |
|---|---|---|
FieldSet | fieldset | Groups related fields. |
FieldLegend | legend | Section heading for a FieldSet; supports legend and label variants. |
FieldGroup | div | Vertical stack for multiple related fields. |
Field | div | Main layout wrapper with orientation variants. |
FieldContent | div | Groups the control, helper text, and error message. |
FieldLabel | Label | Shared label styling with invalid-state awareness. |
FieldTitle | div | Heading-style label for non-input sections. |
FieldDescription | p | Supporting copy for context or constraints. |
FieldSeparator | div | Section divider with optional inline label. |
FieldError | div | Alert-styled error output; can render children or an errors array. |
Field
| Prop | Type | Default |
|---|---|---|
orientation | "vertical" | "horizontal" | "responsive" | "vertical" |
className | string | undefined |
Field also accepts normal div props such as data-invalid, id, and children.
FieldLegend
| Prop | Type | Default |
|---|---|---|
variant | "legend" | "label" | "legend" |
FieldError
| Prop | Type | Notes |
|---|---|---|
errors | Array<{ message?: string } | undefined> | When present, the component renders the message list automatically. |
children | React.ReactNode | Overrides automatic error rendering when you need custom text. |
All remaining exports forward their native element props directly.