Contrast ratio
The contrast ratio is WCAG's measure of how far apart two colours are in relative luminance, computed as (L1 + 0.05) / (L2 + 0.05) and written from 1:1 to 21:1. WCAG 2.2 at level AA asks for 4.5:1 for normal text, 3:1 for large text and 3:1 for the parts of controls and graphics people need to see. Meadowstack checks every text and surface pair of its palette against these floors, in both themes.
By Bohuslav PoláčekChecked
const surfaces = ["frame", "canvas", "surface", "surface-subtle", "surface-hover", "surface-active", "surface-raised"];
// [text, background, WCAG minimum, APCA floor for text]; a pair under 4.5:1 is a mark and has no Lc floor.
const pairs = [
...["fg", "fg-muted"].flatMap((fg) => surfaces.map((bg) => [fg, bg, 4.5])),
...surfaces.map((bg) => ["fg-subtle", bg, 4.5, apcaThresholds.regular]),
["fg", "selection", 4.5],
["fg-inverse", "surface-inverse", 4.5],
["primary-fg", "primary", 4.5],
["primary-fg", "primary-hover", 4.5],
...["info", "success", "warning", "danger"].map((tone) => [`${tone}-fg`, `${tone}-subtle`, 4.5]),
...["info", "success", "warning", "danger"].map((tone) => [`${tone}-fg`, "surface", 4.5]),
// Text on a status fill sits on its -solid fill; the mark itself carries an icon at most (a check, 3:1).
...["info", "success", "warning", "danger"].map((tone) => [`${tone}-contrast`, `${tone}-solid`, 4.5]),
...["info", "success", "warning"].map((tone) => [`${tone}-contrast`, tone, 3]),
["danger-contrast", "danger-hover", 4.5],
// The edge that identifies a control: 3:1 wherever a control can sit (WCAG 1.4.11).
...["frame", "canvas", "surface", "surface-subtle", "surface-raised"].map((bg) => ["border-control", bg, 3]),
// Focus ring: 3:1 on every surface a focused control can sit on (WCAG 1.4.11).
...["frame", "canvas", "surface", "surface-active", "surface-raised"].map((bg) => ["ring", bg, 3]),Why it matters in a business app
Business apps lean on grey: a muted date beside a customer's name, a column header, a disabled button, a placeholder. Each is a pair of colours, and each pair changes in every state: the hovered row, the selected row, the sidebar. A grey that passes on white can fail on the selected row's fill, which is exactly where people are looking.
A failed pair is rarely one screen. It is a token, so it fails on every screen that uses it.
How Meadowstack handles it
- Floors in the generator. The palette generator pushes each text level away from the page until it clears its floor:
fg12:1,fg-muted7:1,fg-subtle4.6:1, the focus ring and control edges 3:1. On the light page panel that gives 15.9:1, 7.1:1 and 5.3:1. - A guard on the tokens.
npm run check:contrastreads the generated palette and measures every pair in the artifact, in light and dark. It runs in seconds and catches a client theme that breaks a screen no test opens (--css client-theme.css). - Every state. AGENTS.md: text contrast at least 4.5:1 in every state, hover included; darker hover tokens, never
opacityon coloured buttons. - On the screens. The end-to-end tests run axe in light and dark.
For small text, Meadowstack also reads the perceptual APCA score on top of the ratio; try pairs in the contrast checker.
Common mistakes
- Checking the resting state only. Hover and selected fills move the background under the text.
- Opacity for muted text or hover. The result depends on what is underneath, so no token can promise it.
- Large-text rules for 13px. The 3:1 allowance is for text from 18pt, or 14pt bold, not for table text.
- Colour as the only signal. Enough contrast does not help someone who cannot tell red from green; put the word next to the colour.
Sources
Questions
What contrast ratio does WCAG require for text?
At level AA, 4.5:1 for normal text and 3:1 for large text, which WCAG defines as at least 18 point, or 14 point bold.
Does the contrast ratio apply to buttons and icons?
Yes, through 1.4.11 Non-text Contrast at level AA: the visual parts of controls and graphics people need to understand them need 3:1 against adjacent colours.
Why does a colour pair pass in light mode and fail in dark mode?
Each theme has its own values for the same roles, so each pair is a new measurement. Check both themes, and every state such as hover and selected.
Is APCA replacing the contrast ratio?
Not in WCAG 2.2, which still uses the ratio. Meadowstack keeps the ratio as its floor and reads APCA's Lc on top for small text.
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app