# Accessibility Accessibility is part of "done". It is cheap to build in from the first commit and expensive to retrofit, and the people it protects are not a small group: anyone on a phone in sunlight, anyone using a keyboard, anyone whose first language is read right to left. ## Measure contrast, don't judge it Eyes lie, especially on your own monitor. Measure. | Text | Minimum ratio | | --- | --- | | Small text (under 18px, or under 14px bold) | **7:1** | | Any other text | 4.5:1 | | Large text, icons, input borders, focus rings | 3:1 | 7:1 for small text is stricter than the WCAG AA minimum of 4.5:1. It is the AAA level, and it is what keeps small labels readable on a phone outdoors. [templates/a11y/contrast.ts](../templates/a11y/contrast.ts) is a 15-line function that returns the ratio between two hex colours, and its spec pins known values. A brand colour is usually the problem. A saturated blue such as `#0059ff` on a near-black `#101820` measures 3.3:1. That is fine for a large heading or a filled button, and unreadable as a 12px label. So: - **Brand colours are for fills, borders and large text.** Small text uses a neutral token with a measured ratio. - **Define text colours as design tokens** and check the token pairs once, rather than checking every screen. - **Check dark mode separately.** A pair that passes on white can fail on dark. ## Meaning never rides on colour alone A red border is not an error message. Pair every colour signal with text, an icon or a pattern: - An invalid field shows an icon and a message, and the control has `aria-invalid="true"`. - A status is a word ("Paid", "Cancelled") as well as a colour, and a chart series has a label or a pattern as well as a hue. - A required field says "required" in text, not only with a coloured asterisk. ## Keyboard and focus - Every interactive element is reachable with Tab, in reading order, and operable with Enter or Space. Use a real `