Field
The accessibility contract shared by every form control — label, help text, error, success and the ARIA wiring that connects them.
Live preview
Source
The exact file rendered in the preview above.
components/demos/field.tsx
components/ui/field.tsx
Demo source — adapt to your project. Foundry is not published as a package.
Usage
Wrap every control in a Field. The render prop hands back exactly the props the control needs, which makes it structurally impossible to ship a field whose help text is not associated with its input.
- Ids are derived from `name` rather than `useId`, so a form renders identically on the server and works before hydration.
- Mark the exception: if most fields are required, mark the optional ones with `showOptional` instead of starring everything.
- Errors are strings, not booleans — "Required" is not an error message, "Enter your work email" is.
- Use Fieldset for radio groups and checkbox groups; a group needs a legend, not a floating label.
Variants and states
Every entry below is a genuine difference in behaviour or layout, and every one of them is visible in the preview above.
- Plain — label and control only
- With help text — wired through aria-describedby
- Required and Optional marking
- Invalid — error joins the description, it does not replace the hint
- Valid — confirmation after a successful check
- Hidden label — visually hidden, still announced
- Fieldset — legend and shared description for grouped controls
Accessibility
- Association
- The label uses `htmlFor`, and hint, error and success ids are joined into one `aria-describedby`.
- Invalid state
- `aria-invalid` is set from the presence of an error, never from a separate boolean that could drift.
- Colour independence
- Errors carry an icon and text; the red border is the third signal, not the only one.
- Grouping
- Fieldset applies the same description and invalid wiring at group level via `aria-describedby` on the fieldset.
Foundry implements published ARIA patterns and is tested against them. No WCAG certification is claimed — see the accessibility documentation for what is and is not covered.
Related
All componentsInput
Single-line text entry with leading and trailing slots, three sizes and a shared control surface used by every other text control.
starter7 variantsCheckbox
Multi-select control with inline and card appearances, plus a genuine indeterminate state for bulk selection.
starter5 variantsRadio group
Mutually exclusive choice, with a card appearance for decisions that need explanation.
starter4 variantsRegister
Account creation with a live password-strength meter that is announced as words, not bars.
intermediateFeatured5 variants