Founding price: $35, then $79.99 after 23:59 UTC on 4 November, then $79.99
Get ProCheck text and background colors against WCAG 2.2 contrast: the ratio (never rounded up), AA, AAA and non-text results, a live preview, swap, and a button that suggests the closest foreground that passes.
This item has no props to tune. Use the lens above to change theme, density, direction and more.
It implements the WCAG 2.2 contrast ratio. APCA, the model proposed for WCAG 3, is not included and gives different results, especially for light text on dark backgrounds.
| Export | Description |
|---|---|
ContrastChecker | The two fields, preview, results and suggestion. |
contrastRatio(fg, bg) | WCAG ratio, with transparent foregrounds flattened onto bg. |
wcagResults(ratio) | { aaNormal, aaLarge, aaaNormal, aaaLarge, ui }. |
suggestForeground(fg, bg, target?) | The nearest passing foreground, or null. |
displayRatio, relativeLuminance, flatten | Helpers. |
| Prop | Type | Default | Description |
|---|---|---|---|
defaultForeground, defaultBackground | string | #6b7280, #ffffff | Starting colors. |
onChange | ({ foreground, background, ratio }) => void | - | After a valid change. |
sampleText | string | pangram | Text in the preview. |
role="status" region, so a change in the ratio is announced politely. Pass and Fail are words with an icon, not only green and red.The component ships with a Testing Library test (contrast-checker.test.tsx) that covers: its main behaviour, the keyboard path and the error or empty states.