1. Why Web Contrast Ratios Matter
Over 2.2 billion people globally live with some form of vision impairment, including cataracts, glaucoma, low vision, and various forms of color blindness (such as deuteranomaly or protanopia). In addition, everyday users frequently interact with mobile screens in direct sunlight, on dimmer battery-saver modes, or with low-quality monitors.
When text lacks sufficient contrast against its background, readability plummets. Under the Americans with Disabilities Act (ADA) in the United States and the European Accessibility Act (EAA), websites offering public services, e-commerce, or commercial content are legally mandated to comply with W3C WCAG standards.
The Mathematical Relative Luminance Formula
WCAG measures contrast through Relative Luminance ($L$), defined as the relative brightness of any point in a colorspace normalized to 0 for black and 1 for white:
Where $L1$ is the relative luminance of the lighter color and $L2$ is the luminance of the darker color. The constant 0.05 accounts for ambient screen flare.
2. Level AA vs. Level AAA Thresholds
- Normal Body Text: Minimum 4.5:1 ratio.
- Large Text (18pt / 14pt bold): Minimum 3:1 ratio.
- Active UI Components: Form borders, toggle buttons, and icons require at least 3:1.
- Normal Body Text: Minimum 7:1 ratio.
- Large Text: Minimum 4.5:1 ratio.
- Recommended for long-form reading, government portals, and legal disclosures.
3. Best Practices for Accessible Tailwind CSS Palettes
- Avoid Light Grey on White: Never use
text-slate-400for body text on a white background. Usetext-slate-600or darker to comfortably exceed 4.5:1. - Don't Rely on Color Alone: When indicating form errors or success states, combine color with icons or textual badges (e.g. an alert triangle icon next to red error text).
- Test Dark Mode Inversions: A color that passes Level AA on a light background will often fail when placed on a dark background unless its lightness channel is elevated.