a11y-toolkit: Contrast ratio + verdicts
a11y_contrast_pairCalculate exact WCAG contrast ratio for a foreground/background color pair, with AA, AAA, and non-text verdicts plus a passing-color suggestion if AA fails.
Instructions
Exact WCAG contrast ratio for a color pair: per-criterion verdicts 1.4.3 (AA), 1.4.6 (AAA), 1.4.11 (non-text). Accepts #hex, rgb(), hsl(), CSS color names; rgba/hsl with alpha is composited over the background. If AA fails, suggests the nearest passing color. — For flat pairs; text over images needs a11y_contrast_image. Returns JSON: {text, background, ratio, verdicts [{criterion, level, threshold, passes}], aa_suggestion?}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bg | Yes | Background color: same formats; alpha composites over white | |
| fg | Yes | Foreground/text color: #hex, rgb(), hsl() or a CSS color name; alpha composites over bg | |
| lang | No | output language (en default) |