0012. Accessible component kit and how it's tested
- Status: Accepted
- Date: 2026-11-24
Context
Later screens need a small set of building blocks that are accessible by construction, so each new screen doesn't re-solve labels, focus, states and target size. ADR 0005 left Preact component testing open.
Decision
- Components in
apps/web/src/components/(a package only when a second app needs them): primary and secondaryButton,TextField, nativeSelectField,AnswerCard(good / tight / bad),Banner(info / caution / bad),FooterLink, and decorativeIcons. - No disabled style. A button that can't act yet stays focusable with
aria-disabled="true", shows a visible reason linked througharia-describedby, and blocks its own action (click, Enter and Space do nothing). A greyed-outdisabledbutton can't be focused, gives no reason and fails contrast. - Fields: a visible label above the field, never a placeholder; hints via
aria-describedby; errors in words with an icon andaria-invalid, inside a live region that exists before the error appears. The order is label, field, hint, error (amended 2026-12: the hint first sat between the label and the field; moving it under the field follows the approved prototype and changes nothing a screen reader hears, because the description is wired by id, not by position). - Icons are inline SVG in
currentColorwitharia-hidden; the words beside them carry the meaning. - Tests: Vitest browser mode (Playwright's Chromium) for behaviour and keyboard, in the same
npm testand runner as the unit tests (apps/web/vitest.components.config.ts). Every component state is on a/gallerypage (made-up sample data, not linked,noindex), which the requiredappCI job checks: axe, 44px targets, CSP, 310% text and forced colours.
Consequences
- New UI uses the kit, or extends it with the same rules and a gallery entry.
- Grid tracks use
minmax(0, 1fr): plain1frcan't shrink below its widest child, which pushed the page sideways at 310% text (found by the gallery check). - Whether
/gallerystays reachable in production is decided with Cloudflare Access (environments phase). - Component tests run in Chromium only; WebKit is covered by the end-to-end
iphoneproject.
Sources
- https://vitest.dev/guide/browser/
- https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/ (focusable disabled controls)