---
name: color-contrast-checker-instructions
description: "Checks a foreground and background color pair against WCAG 2.1 AA and AAA, shows the contrast ratio, and suggests the smallest change that makes a failing pair pass. Use when a designer or developer wants to know if a text and background color pair passes WCAG 2.1 AA or AAA. Do not use for auditing a whole page, checking non-text contrast like icons, or choosing a full palette. Related topics: design, ux, color."
---

# Color Contrast Checker Instructions

Checks a foreground and background color pair against WCAG 2.1 AA and AAA, shows the contrast ratio, and suggests the smallest change that makes a failing pair pass.

## When to use

Use this skill when a designer or developer wants to know if a text and background color pair passes WCAG 2.1 AA or AAA. Do not use it for auditing a whole page, checking non-text contrast like icons, or choosing a full palette.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Convert both hex codes to relative luminance and compute the contrast ratio, showing the intermediate values.
3. Compare the ratio with the AA and AAA thresholds for the stated text size and record pass or fail for each.
4. If the pair fails, find the nearest foreground color of the same hue that passes AA and give its hex and ratio.
5. Note whether the stated use calls for a stricter reading than the size alone suggests.

## Inputs

- **Foreground hex** (free text, e.g. "#767676")
- **Background hex** (free text, e.g. "#FFFFFF")
- **Text size** (choose one: Normal (under 18pt), Large (18pt or larger))
- **Where it is used** (free text, e.g. "Body text or button label or placeholder")

## Output

The contrast ratio, a pass or fail line for AA and AAA, and for failures a replacement hex with its ratio.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Color Contrast Checker Instructions

Check whether this color pair meets WCAG 2.1 contrast requirements.

- Foreground hex: {{Foreground hex}}
- Background hex: {{Background hex}}
- Text size: {{Text size}}
- Where it is used: {{Where it is used}}

Convert each hex to relative luminance using the WCAG formula and compute the contrast ratio, showing the steps briefly. Compare the ratio with the thresholds for the chosen size: AA needs 4.5 to 1 for normal text and 3 to 1 for large text, and AAA needs 7 to 1 and 4.5 to 1.

State pass or fail for AA and AAA. If the pair fails, suggest the nearest foreground hex that passes AA while keeping the same hue, and give its ratio. Note that a pair that passes for large text may still fail for body copy, and say whether the stated use needs a stricter reading.

## Pitfalls

- Using perceived brightness instead of the WCAG relative luminance formula, which gives wrong ratios.
- Applying the large-text threshold to body copy because the font size is borderline.
- Suggesting a fix that shifts the hue away from the brand color.
