colorWCAGLevel
🎨 Returns the WCAG conformance level for the contrast ratio between two colors.
Syntax
TypeScript
import { colorWCAGLevel } from '@opentf/std'; colorWCAGLevel({ color1: any; color2: any }): 'A' | 'AA' | 'AAA' | 'FAIL'
Parameters
| Name | Type | Description |
|---|---|---|
| color1 | any | The first color. |
| color2 | any | The second color. |
Returns
The WCAG conformance level: 'A' (3:1+), 'AA' (4.5:1+), 'AAA' (7:1+), or 'FAIL'.
Examples
TypeScript
colorWCAGLevel({ color1: '#000', color2: '#fff' }) //=> 'AAA' colorWCAGLevel({ color1: '#000', color2: '#999' }) //=> 'AAA' colorWCAGLevel({ color1: '#000', color2: '#767676' }) //=> 'AA' colorWCAGLevel({ color1: '#000', color2: '#595959' }) //=> 'A' colorWCAGLevel({ color1: 'rgb(0,0,0)', color2: 'rgb(255,255,255)' }) //=> 'AAA'