a11y-toolkit: Nearest passing color
a11y_suggest_colorFind the nearest opaque foreground color that meets a target contrast ratio against a background, returning the color, ratio, and lighten/darken action. Fixes WCAG contrast failures.
Instructions
Nearest opaque color (RGB distance) to fg that reaches the target ratio against bg (4.5 default). Returns the color, its ratio and whether it lightens or darkens. — The fixer companion to a11y_contrast_pair failures. Returns JSON: {color, ratio, action} — the nearest opaque color reaching the target.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bg | Yes | The background it must pass against | |
| fg | Yes | The failing foreground color to fix | |
| target | No | Ratio to reach: 4.5 normal text, 3.0 large text/UI, 7.0 AAA (default 4.5) |