Accessibility Colour Contrast Matrix (WCAG 2.2 and APCA)
Test a whole design-system palette at once: a grid of all colour pairs, pass or fail for your chosen rule, nearest passing shades and Markdown or CSS export.
Chạy trong trình duyệt của bạn. Tệp không bao giờ rời khỏi thiết bị. Xem cách tự kiểm tra
…
Cách thực hiện
- 1Set up the palette
Edit the sample swatches or paste your CSS variables or tokens.
- 2Choose a rule
Pick WCAG AA, AAA, large text, UI or an APCA level.
- 3Read the grid
Rows are text, columns are backgrounds; faded cells fail.
- 4Inspect a pair
Tap a cell to preview text sizes and see both scores.
- 5Apply a fix
Use a suggested shade to make the text colour pass.
- 6Export
Download Markdown, CSV, JSON or CSS helper classes for safe pairs.
Giới thiệu công cụ này
Single-pair contrast checkers answer one question at a time: does this grey pass on white? A design system needs the whole picture. With nine colours there are 72 possible text and background combinations, and designers, developers and content editors keep picking new ones. This matrix tests every pair in one view. Rows are text colours and columns are backgrounds, and each cell shows the WCAG 2.2 contrast ratio, the level it reaches (AAA, AA, AA for large text or fail) and the APCA lightness contrast value Lc, the newer perceptual method being developed for future WCAG versions. Pick the rule your team must meet, and failing pairs fade so the usable combinations stand out. Tap any cell to preview real text sizes and a UI border, and get the nearest shade of the text colour that would pass. The safe-pairs list and the exports turn the result into documentation your team can follow.
Building the palette
Start from the sample or replace it. Each swatch has a colour picker, a name and a hex field. To bring in an existing palette, paste CSS custom properties (--brand-600: #2563eb;), lines like Ink #111827, a JSON or design-tokens file with $value fields, or just a list of hex codes; rgb() and hsl() values are converted too. Undo covers every edit, including imports and applied fixes.
Reading the matrix
Choose what to show in the cells: the WCAG ratio, the APCA Lc, or both. The pass rule can be WCAG AA for body text (4.5:1), AA for large text (3:1, which means at least 24 px, or 18.66 px bold), AAA (7:1), non-text UI contrast (3:1 for borders and icons), or APCA Lc 60, 75 or 90. APCA values are signed: positive means dark text on a light background, negative means light text on dark, and the size of the number matters. The matrix is not symmetric for APCA, which is one reason it often disagrees with WCAG on mid-tone colours such as orange and bright blue.
Fixing a failing pair
The detail panel shows the pair with 14 px text, bold large text, a 24 px heading and a bordered UI shape, with both scores and the APCA guidance for what that Lc is good for. Below it the tool searches for the nearest lightness of the text colour, keeping its hue and saturation, that reaches 4.5:1, 7:1 and 3:1, and you can apply a suggestion to the palette with one tap.
Exports
Download the matrix as a Markdown table for a design-system page, a CSV with both scores for every pair, JSON for tooling, or CSS with the palette as custom properties plus one helper class for each pair that passes your chosen rule.
Limits
Contrast is calculated for flat sRGB colours. Transparency, gradients, text over images, font weight and anti-aliasing are not taken into account, and APCA is still a draft method that is not yet part of a published WCAG standard, so for legal conformance today use the WCAG 2.2 result.
Ví dụ có lời giải
The sample palette has nine colours, so 72 pairs. With the rule set to WCAG AA body text, 18 pairs pass and 8 reach AAA. Gray 500 #6b7280 on white gives 4.83:1 and Lc 73.6, a narrow pass. Brand blue #2563eb on white passes at 5.17:1, and white text on brand blue is Lc -80.2, comfortably readable. Warning amber #f59e0b on white fails badly at 2.15:1; the fix panel suggests #a56a07 for 4.5:1. White on Success green #16a34a gets only 3.30:1, fine for large buttons but not body text, while Ink on Warning reaches 8.26:1, so the team documents dark text on amber banners.
Tóm tắt
- Danh mục: Lập trình và dữ liệu
- Chạy trong trình duyệt, không đăng ký, không tải lên.
- Thông tin bạn nhập ở lại trên thiết bị.
- Có bằng tiếng Anh.
- Nội dung được rà soát lần cuối:
- Nguồn chính thức: W3C WCAG 2.2 (1.4.3, 1.4.6, 1.4.11) and APCA-W3 0.0.98G-4g
Câu hỏi thường gặp
What is the WCAG contrast ratio?
A ratio from 1:1 to 21:1 based on the relative luminance of the two colours. Body text needs 4.5:1 for AA and 7:1 for AAA; large text and UI components need 3:1.
What is APCA?
The Accessible Perceptual Contrast Algorithm, a newer model that accounts for polarity and how we perceive light and dark text. It reports Lc values; about 75 suits body text and 60 suits larger content text.
Why do WCAG and APCA disagree?
WCAG's formula overrates contrast for some dark colours and underrates white on mid-tone colours such as orange. APCA corrects for that, so a pair can pass one and fail the other.
Which one should I follow?
For compliance with WCAG 2.2 and laws that reference it, follow the WCAG ratio. Use APCA as an extra quality check, especially for dark mode.
How is the suggested fix chosen?
The tool keeps the hue and saturation of the text colour and changes lightness in small steps until the target ratio is reached, choosing the smallest change.
Is my palette saved?
Yes, as a local draft in this browser only, with full undo and redo.
