check_contrast
Computes WCAG contrast ratios between foreground and background colors and returns PASS/FAIL verdicts for normal and large text to verify AA compliance.
Instructions
Computes mathematical WCAG 2.x relative luminance contrast ratio between foreground and background colors. Non-destructive, read-only computation with no side effects, network access, or authentication. Automatically normalizes 3-digit hex (#fff -> #ffffff), 6-digit hex, and 8-digit hex (ignoring alpha). On malformed hex input, returns a descriptive error specifying expected hexadecimal syntax without throwing unhandled exceptions.
When to use: Call whenever selecting color pairs for text, UI containers, buttons, or badges to verify WCAG AA compliance (>= 4.5:1 for normal body text, >= 3.0:1 for large or bold text >= 18pt). When NOT to use: Do not use for retrieving comprehensive brand styling or palettes; use get_brand_design instead. Returns: Mathematical ratio (e.g. 21.00:1), RGB conversions, PASS/FAIL verdicts for normal and large text, and luminance adjustment suggestions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| background | Yes | Hex color for surface or container. Accepts 3-digit (#000), 6-digit (#08090a), or 8-digit hex strings with or without leading '#'. Case-insensitive. Required. | |
| foreground | Yes | Hex color for text or iconography. Accepts 3-digit (#fff), 6-digit (#ffffff), or 8-digit hex strings with or without leading '#'. Case-insensitive. Required. |