PRIMITIVES
FormField
Accessible wrapper that wires a label, description, and error message to a single input child via aria-describedby and aria-invalid. Ships zero opinions about layout — pair it with Box for stacks.
Import
Label + description
We'll never share it.
Error state
Pass an error string to surface a validation message. The wrapper sets aria-invalid on the child and links the error to aria-describedby.
Username is already taken.
With Textarea
Markdown is supported.
Props
FormField props
| Prop | Type | Default | Description |
|---|---|---|---|
| label* | ReactNode | — | Visible label rendered as a <label> and wired to the child via htmlFor. |
| description | ReactNode | — | Optional helper text. The id is added to the child via aria-describedby. |
| error | ReactNode | — | Optional validation message. When present, it is added to aria-describedby and the child also receives aria-invalid=true. |
| id | string | — | Override the auto-generated id. Useful when you need to reference the field from outside the form. |
| children* | ReactElement | — | Exactly one child element. The wrapper clones it and injects id, aria-describedby, and aria-invalid. |
| labelClassName | string | — | Customise the label classes (e.g. to hide for visually-hidden labels). |
Accessibility
- The label is a real
<label htmlFor="…">; clicking it focuses the input. - Description and error ids are merged into the child's
aria-describedby; existing ids passed by the caller are preserved. - When
erroris set, the child receivesaria-invalid=trueautomatically.