Pattern

Forms and validation

Labels, help text, inline errors, the error summary and validation timing.

Rules

  • Every field has a visible label above it; placeholders are examples, never labels.
  • Validate on submit, then on blur. Never per keystroke, and never for a date of birth while it is being typed.
  • Errors sit next to the field (danger text with an icon, linked by aria-describedby) and in a summary at the top that takes focus and links to each field.
  • Schemas from @edflow/shared raise message keys; the form translates them, so copy stays in the catalogue.
  • Selects are full width with a popup that matches the field; long lists are grouped and scroll.

Live examples

Form · The forms pattern: labels, help, inline errors and an error summary.
Date of birth · Year, month and day in ISO order with a clear hint.
Visit-code input · 8 or 10 Crockford characters in two mono groups.
Select · A full-width select with a matching popup, groups, scrolling and a check.