Dark mode has evolved from a novelty to an expectation. But implementing it accessibly requires more than inverting your colors. WCAG compliance in dark mode presents unique challenges that many designers overlook.
Dark Mode Challenges
Dark mode isn't simply light mode with inverted colors. It introduces several accessibility considerations that require intentional design decisions.
The Pure Black Problem
Many designers reach for #000000 when implementing dark mode. This is almost always a mistake. Pure black backgrounds create excessive contrast with white text, causing eye strain and making text harder to read for extended periods.
This text on pure black creates harsh contrast. While it technically passes WCAG contrast ratios, it causes eye strain during extended reading sessions.
This elevated black (#0F0F0F) with slightly dimmed white (#E5E5E5) is easier on the eyes while maintaining excellent readability and WCAG AA compliance.
Halation Effect
White or bright text on dark backgrounds can create a "halation" or "glow" effect, especially for users with astigmatism. This makes text appear fuzzy or blurry. The solution: slightly reduce text brightness.
Pro Tip: Use #E5E5E5 or #DEDEDE for body text on dark backgrounds instead of pure white. This maintains contrast while reducing halation.
Contrast in Dark Mode
WCAG AA requires a 4.5:1 contrast ratio for normal text and 3:1 for large text. This doesn't change in dark mode—but achieving it does.
The Math Still Matters
Just because your light mode palette passes WCAG doesn't mean the inverted version will. You need to test every color combination independently.
Dark Mode Contrast Examples
Secondary Text Colors
In light mode, you might use #6B6B6B for secondary text. In dark mode, you need a different shade:
Color Shifts and Perception
Colors appear differently on dark backgrounds. A vibrant blue that looks perfect in light mode might be overwhelming in dark mode.
Desaturate Bright Colors
Highly saturated colors on dark backgrounds can cause visual vibration and eye strain. The solution: reduce saturation by 15-25% for dark mode.
Increase Lightness
Dark colors that work as accents in light mode become invisible in dark mode. Increase their lightness value:
Borders and Dividers
Subtle borders in light mode need to be brighter in dark mode to remain visible:
Testing Methods
1. Use Browser DevTools
Chrome and Firefox have built-in emulation for prefers-color-scheme:
- Chrome: DevTools → Rendering → Emulate CSS media feature prefers-color-scheme
- Firefox: DevTools → Settings → Enable dark theme
2. Contrast Checkers
Test every text/background combination:
- WebAIM Contrast Checker: webaim.org/resources/contrastchecker/
- Contrast Ratio: contrast-ratio.com
- Accessible Colors: accessible-colors.com
3. Real Device Testing
OLED screens render pure black differently than LCD. Test on actual devices:
- iPhone (OLED) - Check for halation and burn-in risk
- iPad (LCD) - Verify contrast ratios hold
- Android phones - Test across different manufacturers
4. Accessibility Extensions
- axe DevTools: Automated accessibility testing
- WAVE: Visual feedback on accessibility issues
- Stark: Color-blind simulation
Implementation Guide
CSS Custom Properties Approach
The cleanest way to implement dark mode is with CSS variables and prefers-color-scheme:
Manual Toggle (Optional)
Some users prefer to control dark mode independent of system settings:
Complete Accessible Dark Mode Palette
Image Handling
Images with white backgrounds look jarring in dark mode. Consider these approaches:
Testing Checklist
- Verify all text meets WCAG AA contrast (4.5:1 minimum)
- Check large text meets WCAG AA contrast (3:1 minimum)
- Test on OLED screen for halation effects
- Validate focus indicators are visible
- Ensure images have adequate treatment
- Test with actual users who prefer dark mode
- Run automated accessibility audits (axe, WAVE)
Conclusion
Accessible dark mode requires deliberate color choices that go beyond simple inversion. By using elevated blacks, maintaining proper contrast ratios, adjusting color saturation, and thoroughly testing your palette, you can create dark mode experiences that are both beautiful and accessible to all users.
Remember: dark mode is about reducing eye strain and improving readability in low-light conditions. If your dark mode causes more strain than light mode, you've missed the point.