Forms
Field & label
Labels, hints, errors and form layout.
Usage
Wrap one control in a Field with a Label and, optionally, a FieldHint or FieldError. The field generates the id, points the label at the control and wires aria-describedby, aria-invalid and required for you. Inputs, textareas and selects work standalone too.
When to use
- Every form control that needs a visible label, helper text or a validation message.
- A group of related controls under one heading — use
FieldsetandLegend. - A page-level form where fields should share one vertical rhythm — use
Form.
Not for: a control that has no label by design (give it an aria-label instead), or a single checkbox or switch with its own inline label.
Validation messages
Render a FieldError with text when the value is wrong. It rises in, marks the control aria-invalid, joins aria-describedby and is announced politely. It renders nothing when its children are empty, so you can pass the message straight from state. Tab out of the email field, or press Create account.
Horizontal layout
Use orientation="horizontal" for settings pages: the label sits in a left column, the control and its messages in the right. Below 640px it stacks again.
Fieldset and form
Fieldset and Legend are the native elements, so a disabled fieldset disables everything inside it. Form is a native form on a grid with a 20px gap.
API
Field
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | 'vertical' | 'horizontal' | 'vertical' | Stack the label above the control, or put it in a left column. |
| required | boolean | false | Sets required on the control and shows the * marker on the label. |
| invalid | boolean | false | Sets aria-invalid on the control. A rendered FieldError does this by itself. |
| disabled | boolean | false | Disables the control and dims the label. |
| controlId | string | — | Id for the control. Generated when omitted. A control that has its own id is followed by the label. |
| ...props | HTMLAttributes<HTMLDivElement> | — | Forwarded to the wrapper div, including ref and className. |
Label, FieldHint, FieldError, Fieldset, Legend, Form
| Prop | Type | Default | Description |
|---|---|---|---|
| Label | LabelHTMLAttributes & { required? } | — | A native label. Inside a Field it targets the control. |
| FieldHint | HTMLAttributes<HTMLParagraphElement> | — | Helper text; added to the control’s aria-describedby. |
| FieldError | HTMLAttributes<HTMLParagraphElement> | — | Validation message with an icon. Renders nothing without children. |
| Fieldset / Legend | native | — | Group related fields. disabled propagates to every control inside. |
| Form | FormHTMLAttributes | — | A native form laid out on a grid with a 20px gap. |
| useFieldControl(props) | hook | — | Wire your own control to the surrounding Field: returns id, aria-describedby, aria-invalid, required and disabled. |
Keyboard
Field adds no key handling of its own. Clicking a label focuses its control; the controls keep their native keyboard behaviour.
| Key | Action |
|---|---|
| Tab | Moves between controls in source order. |
| Click on label | Focuses the control (or toggles a checkbox). |
Accessibility
- The label is a real <label htmlFor>, so the control’s accessible name and the larger click target both work.
- Hint and error ids are added to aria-describedby only while those elements are rendered.
- The error uses an icon and text, never colour alone, and role="alert" so it is announced when it appears.
- The required marker is aria-hidden; the control carries the native required attribute.
- Contrast: error and marker text use the destructive text token, measured at 4.5:1 or better in light and dark.
Motion
- FieldError rises in over 220ms with a light blur that clears (soft rise).
- Reduced motion: the message still appears; the movement is dropped.