ui-kit0.0

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.

We send invoices and receipts to this address.

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 Fieldset and Legend.
  • 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.

Longer is stronger. A short sentence works well.

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.

Shown on invoices and in comments.

Used for scheduled reports.

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.

Billing address

API

Field

PropTypeDefaultDescription
orientation'vertical' | 'horizontal''vertical'Stack the label above the control, or put it in a left column.
requiredbooleanfalseSets required on the control and shows the * marker on the label.
invalidbooleanfalseSets aria-invalid on the control. A rendered FieldError does this by itself.
disabledbooleanfalseDisables the control and dims the label.
controlIdstring—Id for the control. Generated when omitted. A control that has its own id is followed by the label.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the wrapper div, including ref and className.

Label, FieldHint, FieldError, Fieldset, Legend, Form

PropTypeDefaultDescription
LabelLabelHTMLAttributes & { required? }—A native label. Inside a Field it targets the control.
FieldHintHTMLAttributes<HTMLParagraphElement>—Helper text; added to the control’s aria-describedby.
FieldErrorHTMLAttributes<HTMLParagraphElement>—Validation message with an icon. Renders nothing without children.
Fieldset / Legendnative—Group related fields. disabled propagates to every control inside.
FormFormHTMLAttributes—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.

KeyAction
TabMoves between controls in source order.
Click on labelFocuses 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.