AX notes · Measurement

4.5:1 contrast in the site build: the dark hover pair that failed for 7 of 11 apps

A contrast rule that lives in one sentence of a doc does not hold. Our site build computes 11 contrast pairs per app and fails if any pair drops below 4.5:1.

By Stephen Website and search 9 min read Last updated

Measuring text contrast 3/3

On a site where each app has its own accent colour, every colour change shifts the contrast of buttons, badges and link text along with it. This site started with one sentence as its rule: white text on the accent must reach 4.5:1. When we reworked the design system in October 2026 and measured again, the hovered outline button in dark mode fell below 4.5:1 for 7 of our 11 apps. Now the build computes 11 contrast pairs per app and fails if any falls short. Below: what that gate catches, what it still misses, and the steps to build the same gate.

Contents (8)
  1. Dark hover contrast at the October rework: 4.17 to 4.66
  2. For 13 days the rule was one line of prose
  3. The dark accent was tuned against a different background
  4. The gate computes 11 pairs per app, 143 today
  5. Swap the CSS pairing and the gate still passes
  6. color-mix() is banned by T3, and dark colours are not hand-picked
  7. From one accent hex to a 143-pair gate in six steps
  8. FAQ

Dark hover contrast at the October rework: 4.17 to 4.66

Each app on this site has a single accent hex in data/apps.json. sds_apps.py computes nine colour tokens from it as CSS text, and build.py writes that to a file. In dark mode the pale background bg-accent-weak is 24% accent mixed into the default dark surface #172131. The dark text colour fg-accent is the accent with its HSL lightness raised 1% at a time until it reaches 4.6:1 on #1D2940, the lightest of the three dark neutral surfaces.

Put fg-accent text on bg-accent-weak, as a hovered outline button would, and the 11 apps at the October 18 rework score: Arrow Knots 4.17, SugarSpeller 4.20, Compress Image 4.27, Flip & Rotate Image 4.31, SugarCard 4.40, SugarAlbum 4.41, AXFamily 4.41, Block Turn 4.58, SugarClip 4.59, Convert Image 4.64, SugarDoc 4.66. Seven are under 4.5 and nine under 4.6.

Bar chart: in dark mode, putting fg-accent text on the weak accent background of an outline-button hover leaves 7 of 11 apps below 4.5:1, the lowest being Arrow Knots at 4.17:1.
Reusing the dark accent as hover text puts 7 of 11 apps below 4.5:1.

Our working notes say a review agent checking the design spec flagged this pair: "7 of 11 apps, lowest 4.17". We could not find the review itself, so we recomputed it from the app list at the rework and got the same numbers. The implementation commit already shipped the fixed pairing: in site.css, .button--outline:hover uses fg-accent-contrast for its text and border.

For 13 days the rule was one line of prose

The commit that first added the site pages, on 20 September 2026, set the default accent in site.css to #00897B ("default accent: SugarCompress"). The same day, the first commit of the utilities app repository listed "compress (temp) #00897B" in its design tokens. Both commits carry an AI co-author trailer. White text on that colour is 4.32:1, and the colour as text on the light background #F6F8FB is 4.06:1.

The next day, the "Design v2" commit in the utilities repository (also AI co-authored) caught it. Its design spec reads "temporary #00897B (4.3:1, fails AA) is replaced by #0F766E.", and another section makes 4.5:1 text contrast in both themes a principle. The site picked up #0F766E (white text 5.47:1) on 5 October, when a commit introduced data/apps.json.

The contrast rule that commit added to AGENTS.md was a field description: accent "(hex, white text on it must reach 4.5:1)". Searching that commit's tools/build.py for lumin, contrast or 4.5 finds nothing.

The first assumption matched the line: if white text clears 4.5:1 on the accent, the accent is safe. But one accent becomes nine tokens per theme, and those tokens meet as text and background in 11 pairs. Today every white-on-accent pair across the 13 apps is 5.45:1 or higher, while the dark hover pair from the same accents goes down to 4.17.

The dark accent was tuned against a different background

The dark hover used fg-accent for text and bg-accent-weak for the background. fg-accent only guarantees 4.6:1 on #1D2940 (relative luminance 0.0222), and for the blue and teal apps the pale background is lighter than that. Arrow Knots' bg-accent-weak, #14344E, has a luminance of 0.0315, and the same text colour #0A99EE falls from 4.71 to 4.17. The purple and magenta apps passed because their pale backgrounds sit close to #1D2940: Convert Image (#2C2359, 0.0246) at 4.64 and SugarDoc (#32223C, 0.0215) at 4.66.

A second assumption, made while writing this note, was that raising the target to 4.6 would cover the hover too, but the 4.6 target is measured on #1D2940, so with today's formula the pair on the pale background is still 4.17.

The fix is a token per pair. fg-accent-contrast takes the dark accent and lightens it again, 1% at a time, until it reaches 4.6:1 on the pale background. For Arrow Knots that moves #0A99EE to #17A2F5 and 4.17 to 4.61. The header of sds_apps.py states the rule as T2: "text on bg-accent-weak is fg-accent-contrast".

The gate computes 11 pairs per app, 143 today

Inside python tools/build.py --check, which AGENTS.md says to run before every commit, sds_gates() checks three things. The rest of that check is described in Keeping a static site safe when several AI agents edit it: one --check before every commit.

The docstring explains the 4.6 target: "targets are 4.6:1 so rounding and browser blending never drop below 4.5:1". Every mix and lightness step rounds RGB to integers. Because of that margin, Block Turn (4.58) and SugarClip (4.59) also got their own token, and in the dark block of the generated CSS at the rework, 9 of 11 apps declare a separate fg-accent-contrast.

We also ran a revert test. Setting Compress Image back to #00897B in the copy's apps.json made the gate print this (run with --check on 3 November, confirmed through audit() on 4 November):

error: SDS contrast sugarcompress: white on accent, accent on basement
1 gate error(s)

Two apps arrived later, CarDrawer (19 October) and TrimBox (31 October). Each added one hex to apps.json, and the colour code did not change through 4 November. The gate then computed 13 apps x 11 pairs = 143 pairs. As of 4 November, had the hover kept fg-accent, 9 of the 13 would have been under 4.5, with TrimBox at 4.22 and CarDrawer at 4.39.

Update, 13 November 2026: a site-wide colour refresh that day changed the dark neutral surfaces (the darkest is now #0E1217), and the tokens were recomputed by the same functions. After the refresh the lowest of the 143 pairs is AXFamily's dark accent text at 4.60:1. Had the hover kept fg-accent, 3 of 13 apps would now be under 4.5 (Compress Image and Arrow Knots at 4.39, Flip & Rotate Image at 4.48). Because the gate recomputes from the same formula, no colour had to be fixed by hand.

Two copies of the 'Arrow Knots privacy policy' outline button on a dark background; on the right, hovered, the background turns deep blue and the text gets slightly lighter.
The outline button on the live site in dark mode, at rest (left) and hovered (right). Hover text #0A9CF3 on #132E40 measures 4.73:1 (13 November 2026, Arrow Knots app page).

Swap the CSS pairing and the gate still passes

On 3 November we changed the site.css in a copy of the site so the hover text was var(--sds-fg-accent) again, rebuilt, and ran --check, which printed up to date; gates passed with the 4.17:1 pair back in the stylesheet. The only thing sds_gates() reads from site.css is the header mark regex; contrast comes entirely from the token pairs listed in audit().

As of 4 November, site.css used bg-accent-weak as the background in six rules.

SelectorText tokenIn the gate's pairs?
.app-tile:hoverfg-accent-contrastYes
.button--outline:hoverfg-accent-contrastYes
.badgefg-accent-contrastYes
.trust lifg-accent-contrastYes
[data-app] .notebody text fg-neutralNo
.ax-ctanot setNo

On app pages, .note keeps fg-neutral body text (its border, links and the eyebrow use fg-accent-contrast), and .ax-cta sets no text colour at all. Neither pair is among the 11, so neither is measured. We left both unfixed; that call belongs to whoever owns the build.

Both the mistakes and the catches in this history are recorded in AI co-authored commits or agent work. The spec rule that a new accent should be at least dE00 12 (a colour-distance measure) from existing ones was left out of the gate because "the new-key dE00 >= 12 rule needs a human to know which key is new"; the CLI only warns about pairs under dE00 8, currently 7 (smallest 2.2, Flip & Rotate Image and Arrow Knots).

color-mix() is banned by T3, and dark colours are not hand-picked

Letting the browser blend hover colours with CSS color-mix() is banned by rule T3. The gate compares literal hex values in the generated CSS with computed ones, and a browser-blended colour gives it nothing to compare. Hand-picking dark colours per app was dropped too: the site went from 11 apps to 13, and that approach means a person picking nine tokens for every new app.

We measured rendered pixels in another app; that write-up is Our contrast checker passed while skipping 40% of the text. sds_apps.py uses only the Python standard library and never starts a browser.

Without design tokens, with colours written per component, there is no pair list to compute in the first place. Gradients, text over photos and translucent layers don't reduce to two tokens, and this site doesn't measure them either.

From one accent hex to a 143-pair gate in six steps

  1. Keep one accent hex per brand or app in your source data and derive every other token with a function.
  2. Write down every text-on-background pair. Then search the CSS for rules that use each background token (grep -n "accent-weak" assets/site.css) and check each rule's text token against your list, as in the table above.
  3. Aim a little above 4.5 (we use 4.6), and give any pair that falls short its own token.
  4. Fail the build check when any pair is under 4.5:1, and compare the generated CSS values with the computed ones.
  5. Put an old failing colour into apps.json and run python tools/build.py --check: expect a line containing 1 gate error(s), and a line containing up to date; gates passed again once you revert. Then deliberately mismatch a CSS pairing, rebuild with build.py and run --check. Here it still says gates passed.
  6. Run python tools/sds_apps.py to print the colour-distance warnings and have a person look; today it lists 7 pairs under dE00 8.

Don't leave a contrast rule as a sentence in a doc. Make the build compute it from a list of colour pairs, and check that the list matches the pairs your CSS actually uses. We have only done the first half. The next step is a --check stage that extracts the text token of every rule with a bg-accent-weak background and compares it with the 11 pairs, and before that, measuring the .note body text and the .ax-cta text for the first time.

FAQ

Which text does the WCAG 4.5:1 contrast minimum apply to?

Normal-size text. WCAG 2 success criterion 1.4.3 sets 4.5:1 for normal text and 3:1 for large text. Our gate ignores text size and applies 4.5:1 to all 11 pairs.

How is a contrast ratio calculated?

Take the relative luminance of both colours, L1 for the lighter and L2 for the darker, and compute (L1 + 0.05) / (L2 + 0.05). Relative luminance linearises the sRGB channels and sums 0.2126 R + 0.7152 G + 0.0722 B. The contrast() function in sds_apps.py is this formula.

Sources: the site repository's git history and its colour-token module (tools/sds_apps.py), and the design docs in our utilities app repository. Ratios were recomputed on 3 and 4 November 2026 in a copy of the site with that module's functions; the values after the 13 November refresh and the live screenshot are from that day.

This note is written from values SugarMount measured itself; an AI coding agent was used to draft it.

All AX notes