Skip to content

fix(a11y): make white button labels readable in every state, not just at rest - #711

Merged
EVWorth merged 1 commit into
mainfrom
fix/button-fill-contrast
Sep 17, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/button-fill-contrast

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Wave 3 of the UI review.
Closes #703.

The finding, which is not what #703 said

35 white-on-fill combinations were below AA, and almost all of them were the
hover state
, not the resting one:

2.13  hover amber-500   ProcessListTab.tsx:215
2.22  hover green-500   QueryToolbar.tsx:144      ← Run
3.22  rest  green-600   QueryToolbar.tsx:144      ← Run
3.68  hover brand-500   × 23 buttons
3.81  hover red-500     × 5

A button sat at a perfectly legible bg-brand-600 and then lightened on
hover to 3.68:1 — legible right up until you reached for it. Hover is the state
a person is in at the moment they're reading the label to decide whether to
click.

So resting colours are left alone wherever they already passed: the app looks
identical until you point at something. Hovers move a rung darker instead of
lighter. Three resting states did fail and moved up — Run, kill-process, and
the error boundary's retry.

Where #703 was wrong

I wrote it, and it was wrong twice:

The trap: the rung that carries white text differs by hue. Red and blue
manage it at 600; green, amber and yellow don't until 700, because a saturated
mid-green is far lighter than a mid-red at the same number. bg-green-600
reads as the safe choice and isn't one — and it was painting the most-pressed
control in the product.

The guard

src/__tests__/button-contrast.test.ts walks every component source, finds
each text-white element's fill class, and computes contrast from the
palette's real sRGB values — read out of the compiled stylesheet, because
Tailwind v4 restated its palette in OKLCH and the numbers moved.

Three properties worth noting:

  • It asserts it found buttons (>20), so a refactor can't make it pass by
    finding nothing.
  • A class it has no value for fails a test of its own rather than being
    skipped, so it can't rot into a no-op.
  • bg-red-500/20 tints are excluded — those are panel backgrounds with no
    label on them.

Verified it fails: reverting one button gives
ErrorBoundary.tsx:51 resting bg-brand-500 is 3.68:1. It caught that for real
mid-change, when a git checkout quietly reverted the fix to that file.

Verification

  • 2,931 unit tests, lint, dprint, tsc pass
  • Re-measured in the running app: 0 failing white-on-fill combinations, down
    from 35

🤖 Generated with Claude Code

… at rest

Thirty-five white-on-fill combinations were below WCAG AA, and almost all of
them were the *hover* state rather than the resting one. A button sat at a
perfectly legible `bg-brand-600` and then lightened to `bg-brand-500` on hover,
dropping to 3.68:1 — legible right up until you reached for it. Hover is the
state a person is in at the moment they are reading the label to decide whether
to click it.

Resting colours are left alone wherever they already passed, so the app looks
the same until you point at something. Hovers move a rung darker instead of a
rung lighter. Three resting states did fail and moved up: the Run button, the
kill-process button, and the error boundary's retry.

The trap this encodes: the rung that carries white text is not the same across
hues. Red and blue manage it at 600; green, amber and yellow do not until 700,
because a saturated mid-green is far lighter than a mid-red at the same number.
`bg-green-600` reads as the safe choice and is not one — it is 3.22:1, and it
was painting the Run button, which is the most-pressed control in the product.

#703 said this was 38 places on the brand ramp. That was wrong twice over: the
count double-counted, because `bg-brand-500` matches inside `hover:bg-brand-500`,
and the worst offenders were not brand colours at all but hardcoded greens and
ambers, which the issue attributed to #706.

The test walks every component source, finds each `text-white` element's fill
class, and computes the contrast from the palette's real sRGB values — read out
of the compiled stylesheet, because Tailwind v4 restated its palette in OKLCH
and the numbers moved. A class it does not have a value for fails a test of its
own rather than being skipped, so the guard cannot rot into a no-op.

Verified it fails: putting one button back produces
"ErrorBoundary.tsx:51 resting bg-brand-500 is 3.68:1". It caught that for real
during this change, when a `git checkout` quietly reverted the fix to that file.

Closes #703.
@EVWorth
EVWorth merged commit 92d9f8d into main Sep 17, 2026
12 checks passed
@EVWorth
EVWorth deleted the fix/button-fill-contrast branch September 17, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2][a11y] Primary action buttons fail AA — white on accent is 3.22:1 at 12px

1 participant