Skip to content

Packs / accessibility-public

color-contrast-check

Check text and UI colour pairs against WCAG contrast ratios (AA/AAA, normal and large text)

L2 Checks passed 3 of 3 runsv1.0.0Tech-Realm/space-accessibility-public

Install

logicpacks pack use accessibility-public/color-contrast-check
get_pack accessibility-public/color-contrast-check

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

None.

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: local-python
  • Checks: 1 in outcome/checks.yaml
  • Code: contrast.py
  • Tools: python3

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Goal

Contrast ratio and AA/AAA pass/fail for each foreground/background pair (hex), plus the nearest passing darker/lighter foreground for failures.

Verified by: Known values: #000/#fff = 21.00; #777/#fff = 4.48 (fails AA normal); suggestion for #777 on white passes 4.5.

Steps

  1. List the design's text/background pairs (design tokens).
  2. Run python3 code/contrast.py pairs.txt.
  3. Replace failing colours with the suggested ones or adjust the palette.

Edge cases

  • Transparent colours must be flattened against their background first.
  • Text over images needs a check against the worst-case pixel area.

Don'ts

  • Don't claim WCAG conformance from automated checks alone; automated tools catch roughly a third of issues, so do a manual keyboard and screen-reader pass too.