Framework · Imagery · 3 min read
Text-over-image contrast check
A five-step check for text on photos: find the spot most like the text, measure it, tune one scrim for the worst photo and every crop, and make it part of the component.
- 1Find
The spot behind the text most like the text.
Lightest, for white text - 2Pick
Its colour with an eyedropper, at the size it ships.
Two colours: text, spot - 3Check
4.5:1 for text, 3:1 for large text and icons.
4.48 is a fail - 4Tune
One scrim, strong enough for the worst photo in the set.
Not for the mockup photo - 5Lock in
Recheck every crop, then make the scrim part of the component.
A token, not a one-off
Use it when
- A hero, card or banner puts text on photos that change, from a CMS, a library or users.
- A review asks "is this readable?" and the answer is a squint, not a number.
- A component passes in the mockup and someone reports a headline that disappears on one photo.
How to use it
- Find the worst spot. Look behind the text for the part most like it: the lightest area behind light text, the darkest behind dark text. W3C measures text over images against those parts (failure F83). Output: one marked spot per photo.
- Pick its colour. Use an eyedropper in Figma, the browser's developer tools or any image editor, at the size the photo really ships. Output: two colours, the text and the spot.
- Check the pair. Text needs 4.5:1, large text (18 pt, or 14 pt bold) and icons need 3:1. Round down, never up: 4.48 is a fail. Output: a ratio and a pass or fail per photo.
- Tune one scrim for the worst photo. Raise the scrim's opacity until the worst spot passes, then check that the other photos don't turn into dark rectangles. Output: a scrim colour, opacity and stops.
- Recheck every crop, then lock it in. A different crop puts a different spot behind the text. Recheck at the smallest and the largest layout, then make the scrim a token of the component. Output: one scrim rule, with the photos it was tested on.
Worked example
The bakery ordering app puts its hero headline in white over a full-width photo of the day's loaves. The mockup's dark, warm shot passes easily. The audit set has four more: loaves on a floured white counter, the shop front in morning sun, a window full of light, the chalkboard by the door. The worst spot is the bright window behind the loaves, #d4d4d4: white on it is 1.48:1. With the lesson's near-black scrim (#0a0a0c), that spot needs 47% opacity to reach 4.5:1, and 32% for 3:1, so the team sets the floor fade at 50% behind the headline and checks that the loaves still look golden, not grey. Change the colours below to try your own spot.
The worked example, live. Pick your own colours: the text, the worst spot behind it (the lightest for light text, the darkest for dark text) and the scrim. The calculator finds the lowest opacity that passes.
Watch out for
- Measuring the average colour. The average of a photo always looks fine. Measure the lightest spot behind light text.
- Tuning on the mockup photo. The calm photo from the mockup is the easiest case. Tune on the worst one in a real set.
- One crop only. Desktop crops often put calm sky behind the text; the phone crop puts the cloud there.
- A text shadow as the fix. A shadow helps the edges of letters. Over a light photo it doesn't make the text pass.
Template
Copy this into the component's definition of done and fill in one row per photo.
Component: ...
Text: colour ... , size ... (normal: 4.5:1, large or icon: 3:1)
Photo set: mockup + lightest + busiest + most colourful + ... (4 or more)
Photo | Crop | Worst spot (hex) | Ratio, no scrim | Ratio, with scrim | Pass?
... | ... | #... | ...:1 | ...:1 | ...
Scrim: colour #... , opacity ...% behind the text, gone by ...% of the height
Tested at: smallest layout ... , largest layout ...
Owner: ... Retest when: a new photo source or a new crop is added