Design System
Forms

Field

A labelled wrapper that lays out the label, control and a hint or error message, wiring aria-describedby and aria-invalid to the control for you.

Purpose

Field is the standard way to build a form row. It owns the label, the required marker and the hint or error text, and wires the control for you: a single element child gets aria-describedby pointing at the message, plus aria-invalid while error is set — so the message is announced with the input rather than orphaned beside it. Composed controls (a wrapped input with an icon, a Select) need the wiring by hand; the message ids are always {htmlFor}-hint / {htmlFor}-error.

Example

We will send claim updates to this address.

This policy number was not recognised.

Structure

PropertyValue
LayoutVertical stack, 6px gap (space-y-1.5)
Label14px / Inter 600, --secondary-foreground
Required markerAsterisk in --destructive, appended to the label
Hint12px --muted-foreground
Error12px / Inter 500, --destructive — replaces the hint

Best practices

Do

  • Always set htmlFor to the control's id — the label pairing and the message ids both derive from it.
  • Let Field do the wiring: a direct control child gets aria-describedby and aria-invalid automatically.
  • Wire composed controls by hand — a wrapped input or a Select needs aria-describedby="{id}-hint" on the control itself.
  • Put format guidance in the hint; write errors as what to do next.

Don't

  • Hand-roll a label and message around a control — the wiring is the point of Field.
  • Expect a hint and an error together: error replaces the hint by design.
  • Rely on the red border alone — error always carries a written message.

Accessibility & keyboard

  • The label is linked through htmlFor, which names the control and makes clicking the label focus it.
  • A single element child is wired automatically: aria-describedby points at the hint or error (ids {htmlFor}-hint / {htmlFor}-error), and aria-invalid is set while error is present — which also triggers the control's error styling. The child's own attributes always win.
  • Composed controls (a wrapper with an icon, a Radix Select) cannot be reached into — set aria-describedby and aria-invalid on the control yourself; the derived ids exist for exactly that.
  • The error state is conveyed by the written message, never by colour alone.
  • Keyboard: none of its own — Field is layout; Tab order belongs to the wrapped control.

Props

PropTypeDefaultDescription
labelReact.ReactNode—Label text rendered above the control.
htmlForstring | undefined—`id` of the wrapped control; links the label and derives the hint/error `id`s.
requiredboolean | undefinedfalseAppends a required marker (a destructive-coloured asterisk) to the label.
hintReact.ReactNode—Helper text shown under the control; hidden while `error` is present.
errorReact.ReactNode—Error message; when set, it replaces the hint and the field renders in its error state.
classNamestring | undefined—Extra classes for the field wrapper.
childrenrequiredReact.ReactNode—The form control (and any adornments) the field wraps. A single element child is wired to the hint/error automatically (`aria-describedby`, plus `aria-invalid` while `error` is set); composed children — a wrapper with an icon, a Radix Select — need `aria-describedby` set on the control by hand.

On this page