WCAG Contrast Validator
Component Detail
Service Layer
low complexity
mobileshared
0
Dependencies
0
Dependents
2
Entities
0
Integrations
Description
Utility service that programmatically asserts minimum contrast ratios (4.5:1 for normal text, 3:1 for large text and UI components) against WCAG 2.2 AA thresholds. Used both at build time for testing and at runtime to validate custom theme configurations.
wcag-contrast-validator
Responsibilities
- Calculate relative luminance for any two colours
- Compute contrast ratio and compare against WCAG thresholds
- Validate all semantic colour role pairs in a given token set
- Return pass/fail results with ratio values for developer diagnostics
Interfaces
getContrastRatio(Color foreground, Color background)
isNormalTextCompliant(Color fg, Color bg)
isLargeTextCompliant(Color fg, Color bg)
isUiComponentCompliant(Color fg, Color bg)
validateThemeTokens(Map<String, Color> tokens)
generateComplianceReport(ContrastTheme theme)
Related Data Entities (2)
Data entities managed by this component