Lab 3
Color Lab
Color contrast checker for whole palettes
Pick a color and see at once whether people can read it. Then bring in a whole palette and see every pair checked together. Three parts: a color picker, a palette matrix, and a terminal theme checker.
What this page shows
Contrast is the difference in lightness between text and what is behind it. Too little and the text is hard to read. The guidelines put a number on it: ordinary text needs a ratio of at least 4.5 to 1, large text and things like icons and borders need 3 to 1. This page measures that number for you, for one color and for a whole palette.
Most palettes are checked once, for body text on white, and called done. Then the muted grey lands on a blue card, the green becomes a border, the accent becomes a link on a dark footer, and nobody checks those. A palette is every pair, and the matrix on this page shows them all. Some pairs will fail. That is fine. The point is to know which pairs you may use for text, which only for borders and icons, and which never.
Pick one color
The picker describes a color with three numbers, the way a modern color model does: lightness, chroma and hue (OKLCH). The payoff is that lightness is the thing contrast depends on, so moving that one slider changes the result in a predictable way. The other two mostly change the look. Pick a color and the panel shows it as text, as a button, and as an icon on four backgrounds, with a pass or fail for each.
What OKLCH is, and what the controls do
OKLCH is a way of writing a color with three numbers that match how people see it. L is lightness, from black to white. C is chroma, how vivid the color is, from grey outward. H is hue, the color family, as an angle around a wheel. Older models such as hue, saturation, lightness (HSL) also have a "lightness", but two HSL colors at the same lightness can have very different contrast. In OKLCH, equal lightness means close to equal contrast, which is why the lab uses it.
- Lightness slider. Moves the color toward black or white. This is the control that fixes a failing color.
- Hue slider. Changes the color family. On its own it barely changes contrast.
- Chroma slider. Makes the color more or less vivid. At high lightness or low lightness, only dull colors fit on a screen, so the slider stops at the edge.
- The wheel. Hue and chroma together. The dark line is the edge of what a screen can show at this lightness. The hatched area beyond it is not a real color, and the lab will not pretend it is.
- Hex field and eyedropper. Type a color, or pick one from anywhere on your screen. Either way it is converted into the three numbers above.
Check a whole palette
Paste anything that has colors in it, or pick them off the screen. The matrix then shows every color as text on every other color, with a tick or a cross on each cell. Press a color to see its details and, for any pair that fails, the nearest color that would pass.
What the controls above the matrix do
- Checking for. Text needs 4.5 to 1. Borders, icons and focus rings need 3 to 1. Pick which you are checking and the ticks and crosses follow.
- Measure with. The WCAG 2 ratio is the number the guidelines ask for and the one used for pass and fail. The Advanced Perceptual Contrast Algorithm (APCA) is a newer measure, explained below, shown for comparison.
- View as. Redraws the palette as someone with a color vision deficiency would see it, or in grayscale, and recomputes every number on those colors.
- This palette is for. Mark the palette as the light or the dark surface. The export at the bottom then writes one block per surface, because a color tuned for one rarely passes on the other.
- ✓ Passes for any text (AAA)
- ✓ Passes for text (AA)
- ✓ Large text, borders and icons only
- ✕ Fails
Why there is a terminal checker here
A terminal theme is a palette too: sixteen colors that all have to be readable as text on one background. It is on this page because it is the same check as the matrix above, with the rules a terminal uses, and because terminal themes are where unreadable colors hide longest. Paste a theme's light and dark variants separately. Each is scored on its own background. The examples loaded here were drawn for this lab and show the usual pattern: the dark variant fails on dim colors, the light variant on bright ones. Reports for well-known themes are at Terminal theme reports.
What you just learned
- A palette is every pair. Text on card, icon on banner, border on surface. The matrix is the whole set, and the band tells you what each pair is allowed to be.
- WCAG 2 and APCA disagree, and that is informative. The ratio treats dark-on-light and light-on-dark the same. APCA does not, and it is stricter about thin, light text on dark. When they disagree, the pair is usually marginal. Pick a different one.
- Simulation changes the numbers, not just the swatches. Contrast is computed on the colors a person sees. A pair that passes in typical vision can fall apart under deuteranopia, and the matrix shows that directly.
- Light and dark are two palettes. The same sixteen standard terminal (ANSI) colors cannot pass on both a light and a dark background. A theme that ships both has to be checked twice.
- Dim is where terminals fail. Bright black (color 8) is the usual comment color. It is also the one most likely to be unreadable. Check it first.
- Same HSL lightness is not the same contrast. Yellow and blue can both sit at HSL lightness 50% and land on opposite sides of 4.5:1. The ratios on this page are computed.
- Score the fill, not the ring around it. A thin border with its own 3:1 contrast is a workaround for a fill you cannot change: a brand color, a status color, a widget that is not yours. It helps a reader find the edge. It does not make the fill pass, which is why the picker draws the ring and leaves it out of the score. Change the fill or the background first; reach for the ring when neither is yours to change.
- Borders and icons have their own floor. Non-text parts need 3:1 against what is next to them (1.4.11). A field border at 1.4:1 is a field nobody can find. The non-text mode checks that floor for every pair.
- The smallest fix is rarely the prettiest. Moving lightness alone keeps the hue and travels further. Mixing toward black or white is the shorter move and drifts grey. The nearest passing button shows both distances so you choose knowingly.
- If it reads in grayscale, it reads. The grayscale view throws hue away. Two colors that only differ in hue become one. Use it before shipping a chart, a status set, or a map.
- One token cannot serve both surfaces. A link color tuned for white fails on near-black, and the other way round. Mark each palette by surface and the export writes two blocks, so no token is asked to do both jobs. The Contrast Circuit shows why one shared color cannot be moved to satisfy both.
The two measures, and the library behind them
WCAG 2 contrast ratio is the number the accessibility guidelines use. It compares how much light two colors reflect and gives a ratio such as 4.5 to 1. It is the pass or fail on this page.
APCA is a newer way of measuring the same thing. It tries to match how readable text actually looks, including that light text on dark reads differently from dark text on light. It is being considered for the next version of the guidelines and is still changing. The lab shows it beside the ratio so you can see when the two disagree, which usually means the pair is marginal. It is never the pass or fail here.
colorjs.io is the open-source color library the picker uses to convert between color models and to compute both measures. It is the same arithmetic the guidelines publish, done by a library many people check, so the ratio in the picker cannot drift from the standard. The matrix and the terminal reports use the lab's own small copy of the same formulas.
Fine print on the numbers
The lab uses the published APCA constants (version 0.1.9) and the commonly quoted body-text target of Lc 75. Version 2.2 of the guidelines uses the same contrast ratio as version 2.1. The color vision simulation uses the Machado, Oliveira and Fernandes matrices at full severity, which model dichromacy. Real color vision varies more than three matrices can capture, so treat the simulated view as a warning, not a verdict.
Embed this lab
Host the Color Lab on your own page with one element and one script. It runs entirely in the visitor's browser, sends nothing back, and adds a small credit link.
<div data-a11y-world-lab="color"></div>
<script src="https://a11y.world/embed.js" async></script>
For the Terminal Themes mode on its own, use data-a11y-world-lab="terminal".
The lab's styles are scoped to its own container. If your page sets global styles on buttons or inputs, they apply inside the lab too, which is usually what you want.
Related notes
-
Charts that still read when printed in grey
A chart passes when it still carries its message on a grayscale printer. That means three lightness levels, not three hues; dash and shape before pattern; and labels on the data instead of a legend. This is the rule every chart on this site follows, written down.
-
Fix a failing color with the smallest move
A color fails contrast and you want to change it as little as possible. There are two short paths, lightness alone and a mix toward black or white. They often end at the same place, and when they do not, the difference is hue. Here is how far each one travels, with numbers.
-
Build a palette that passes every pair
Not every pair in a palette has to pass. Every pair you use has to. Here is how to build a palette where the allowed pairs are obvious and the forbidden ones are hard to reach for.
-
Color is never the only signal
Red for error, green for success, blue for links. Take the color away and ask what is left. If the answer is nothing, the state was never communicated.
-
Contrast ratio vs perceived contrast
WCAG 2 gives one number for a color pair. APCA gives a different one, and sometimes a different verdict. Where they disagree is where the pair is marginal.
-
Terminal colors are a contrast problem too
A terminal theme is sixteen colors of small monospace text. Most themes ship with two of them unreadable, and the light variant fails in a different place than the dark one.
-
One brand color cannot serve a light and a dark surface
A link blue used on a navy header and on a pale panel fails on one of them. Moving it to fix the header breaks the panel. The only fix that passes both is two tokens, one per surface. Here are the numbers, and why no single value works.
-
Why your focus ring vanishes in dark mode
A ring designed on a white mockup is a coin toss once the page can be dark. The fix is not a darker ring. It is a second tone.
Built a palette that passes where it matters?
Send the tokens through the form. Good palettes and terminal themes go in the gallery with credit.
Submit to the gallery