contrast
Compute WCAG 2.1 contrast ratio between two CSS colors and return AA/AAA tier flags (normal/large text). Optionally also compute APCA-W3 Lc.
Instructions
Compute the WCAG 2.1 contrast ratio between two fully opaque CSS color strings and return WCAG tier flags (AA/AAA normal/large text). Set apca:true to also get the signed APCA-W3 Lc for text a over background b.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | First CSS color string, e.g. "#000000", "black", "oklch(0 0 0)" (max 256 chars) | |
| b | Yes | Second CSS color string, e.g. "#ffffff", "white", "oklch(1 0 0)" (max 256 chars) | |
| apca | No | When true, additionally compute the APCA-W3 (SAPC-4g) lightness contrast Lc for text `a` over background `b` (returned as `apcaLc`) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ratio | Yes | 2-decimal display value; tier flags derive from the unrounded raw ratio | |
| apcaLc | No | Signed APCA-W3 (SAPC-4g) Lc for text `a` over background `b`, rounded to 2 decimals (positive = dark-on-light, negative = light-on-dark); present only when input `apca` is true | |
| aaLarge | Yes | Meets WCAG 2.1 AA for large text (raw ratio >= 3) | |
| aaNormal | Yes | Meets WCAG 2.1 AA for normal text (raw ratio >= 4.5) | |
| aaaLarge | Yes | Meets WCAG 2.1 AAA for large text (raw ratio >= 4.5) | |
| aaaNormal | Yes | Meets WCAG 2.1 AAA for normal text (raw ratio >= 7) |