# 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.

Checked 2 December 2026. By Bohuslav Poláček. https://meadowstack.com/glossary/contrast-ratio/

*The pairs scripts/check-contrast.mjs measures: each text level on each surface at 4.5:1, control edges and the focus ring at 3:1.*

From `scripts/check-contrast.mjs` in the Meadowstack repository:

```js
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: `fg` 12:1, `fg-muted` 7:1, `fg-subtle` 4.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:contrast` reads 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 `opacity` on 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](https://meadowstack.com/glossary/apca/) score on top of the ratio; try pairs in the [contrast checker](https://meadowstack.com/tools/apca-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.

## 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.

## Sources

- [W3C, Understanding 1.4.3 Contrast (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html), checked 2 December 2026
- [WCAG 2.2, 1.4.11 Non-text Contrast](https://www.w3.org/TR/WCAG22/), checked 2 December 2026

## Related

- [APCA](https://meadowstack.com/glossary/apca/) (Glossary)
- [Dark mode](https://meadowstack.com/glossary/dark-mode/) (Glossary)
- [Contrast checker: APCA and WCAG 2](https://meadowstack.com/tools/apca-contrast-checker/) (Tools)
- [Contrast in business apps: what an audit of our demo found, and how we fixed it](https://meadowstack.com/blog/contrast-in-business-apps/) (Blog)
- [Notice: messages by importance, in one frame](https://meadowstack.com/components/notice/) (Components)
- [StatusLabel: a status as a glyph and a word](https://meadowstack.com/components/status-label/) (Components)
