AscendLab
Article

Check Color Contrast Before Shipping UI Text

Use contrast checks to catch hard-to-read foreground and background pairs before a button, card, badge, or hero section ships.

cssaccessibilitycolorui

Introduction

Color contrast issues usually appear late: the text looked fine on a designer's monitor, but feels faint on a phone outside, in dark mode, or on a cheaper laptop display. A quick contrast check catches the common failure before the color pair lands in production.

Contrast ratio is one focused readability check. It does not judge wording, focus states, motion, keyboard flow, or screen reader behavior. It does answer one useful question: is this foreground and background pair likely to be readable enough for the target text size?

Real-world scenario

You are building a pricing card. The primary button uses white text on a green background, the secondary badge uses pale green text on a tinted background, and the helper text uses muted gray.

The primary button passes easily. The badge looks stylish but fails for small text. The helper text passes on white but fails on a pale card background. Checking these pairs before shipping lets you adjust the tint or text color while the component is still easy to change.

What to test

Normal body text. Small text needs stronger contrast than large display text.

Buttons and badges. Interactive elements often use brand colors, so check the actual foreground and background pair.

Muted helper text. Secondary text can become too faint when placed on cards or tinted panels.

Dark mode pairs. Do not assume a light-mode color pair works after inversion.

Gradient surfaces. Test text against the lightest and darkest parts of the gradient, not just one sampled color.

Example check

Pair:

Foreground: #ffffff
Background: #10b981

If the ratio is not enough for the text size you plan to use, try a darker background, a darker text color, or a larger and bolder text treatment. The right fix depends on the component, not only the numeric ratio.

Common mistakes

Testing the design token but not the final surface. A token may pass against pure white and fail against a tinted card background.

Ignoring text size. Large headings and normal body copy use different thresholds.

Checking only one theme. Light and dark themes need separate checks.

Treating contrast as the whole review. Passing contrast is helpful, but it is only one part of usable UI.

Next steps

Final practical note

Check contrast where the text will actually appear. A color pair that looks good in a palette can still fail inside a real component.

Related docs

Related tools