Fix Contrast
fix_contrastRepair a failing color pair by computing the nearest WCAG 2.2 accessible color, preserving hue and saturation while adjusting lightness to meet the target contrast ratio.
Instructions
Repair a failing color pair: given a foreground and background hex, compute the NEAREST accessible color (hue & saturation preserved, lightness nudged) that meets the WCAG 2.2 target — not just a pass/fail report. Use when audit_accessibility flags a pair and you need the corrected value to ship. For a full pass/fail audit use audit_accessibility; to build a whole palette use generate_color_system.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| adjust | No | Which color to move (default 'foreground' — the text) | |
| target | No | Target contrast ratio (default 4.5 = AA normal text; use 3 for large text/UI, 7 for AAA) | |
| background | Yes | Background hex it sits on, e.g. '#FFFFFF' | |
| foreground | Yes | Foreground/text hex to adjust, e.g. '#9CA3AF' |