Check color contrast
check_color_contrastUse this when the user wants to know whether a text, icon or border colour has enough contrast against a background: a WCAG contrast checker for one colour pair (e.g. "does white text on #F59E0B pass WCAG AA", "contrast ratio of #767676 on white", "what text color for this background"). Returns the computed WCAG 2.x ratio (truncated to 2 decimals, rounded down), AA/AAA results for normal text, large text and UI components, a verdict for a given font size, APCA Lc as draft information, and the nearest passing colours for AA and AAA (darker and lighter, same OKLCH hue and chroma). Accepts hex, 8-digit hex with alpha, rgb(), hsl(), hwb(), lab(), lch(), oklab(), oklch(), color(display-p3 ...) and CSS colour names; wide-gamut colours are clipped to sRGB with a note. Does not read colours from images or web pages, resolve CSS variables or currentColor, or check gradients as a whole (check each stop). For 3 or more colours use check_palette_contrast.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bold | No | Optional: true when that text is bold (font-weight 700+), e.g. true. Bold text from 18.66px counts as large text. | |
| adjust | No | Which colour the suggested fixes change, e.g. foreground. auto (default) changes the more colourful of the two, so brand colours keep their hue. | |
| background | Yes | Background colour behind it, e.g. #FFFFFF, white or #1E293B. A translucent background is composited over white. | |
| foreground | Yes | Text, icon or border colour, e.g. #767676, #1E6FD980 (8-digit hex with alpha), rgb(118, 118, 118), hsl(214 76% 48%), oklch(55% 0.18 255) or a CSS colour name such as navy. Translucent colours are composited over the background. | |
| font_size_px | No | Optional text size in CSS pixels for a single verdict on that text, e.g. 16. 18pt = 24px; 14pt = about 18.66px. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apca | Yes | ||
| kind | Yes | ||
| wcag | Yes | ||
| fixes | Yes | ||
| ratio | Yes | ||
| request | Yes | ||
| warnings | Yes | ||
| ratio_4dp | Yes | ||
| your_text | Yes | ||
| background | Yes | ||
| foreground | Yes |