- Body text is the most common element users interact with
- 7:1 ensures readability in all conditions (bright light, low-quality screens)
- It future-proofs your theme for stricter standards
- UI components still use AA (3:1), balancing accessibility with design flexibility
WCAG Overview
Theme Gen enforces Web Content Accessibility Guidelines (WCAG) to ensure your themes are usable by everyone, including people with visual impairments.Contrast Ratio Requirements
WCAG defines minimum contrast ratios between foreground and background colors. Theme Gen checks these automatically and helps you create compliant themes.WCAG Levels
WCAG AA (Minimum)
WCAG AA (Minimum)
Level AA is the baseline accessibility standard most websites should meet:
- Normal text (< 18pt or < 14pt bold) - 4.5:1 contrast ratio
- Large text (≥ 18pt or ≥ 14pt bold) - 3:1 contrast ratio
- UI components (buttons, form borders, focus indicators) - 3:1 contrast ratio
WCAG AAA (Enhanced)
WCAG AAA (Enhanced)
Level AAA provides enhanced accessibility for users with low vision:
- Normal text (< 18pt or < 14pt bold) - 7:1 contrast ratio
- Large text (≥ 18pt or ≥ 14pt bold) - 4.5:1 contrast ratio
Theme Gen Contrast Requirements
Theme Gen enforces specific contrast ratios based on how colors are used:Why These Specific Ratios?
Text on Background - 7:1
This is the WCAG AAA standard. Body text appears most frequently in your UI, so Theme Gen uses the strictest requirement to ensure maximum readability.This high contrast benefits:
- Users with low vision or color blindness
- Reading on mobile devices in bright sunlight
- Older displays with lower contrast ratios
- Users with temporary vision impairment (eye strain, fatigue)
Primary on Background - 3:1
Primary colors are used for buttons, links, and interactive elements. The WCAG AA standard of 3:1 ensures these UI components are distinguishable from the background.
Text on Container - 4.5:1
Containers (cards, panels, modals) often have a different background than the main page. WCAG AA requires 4.5:1 for normal text, which Theme Gen enforces for text on containers.This ensures text remains readable even when containers are close in color to the page background.
Contrast Calculation
Theme Gen uses the WCAG 2.1 relative luminance formula to calculate contrast ratios:Understanding the Formula
Why Not Just Use RGB Values?
Why Not Just Use RGB Values?
Human vision is not equally sensitive to all colors. We perceive green much more strongly than blue, and red falls in between.The
relativeLuminance function:- Converts RGB to linear space (removes gamma correction)
- Applies ITU-R BT.709 coefficients that match human perception:
- 21.26% red
- 71.52% green (we’re most sensitive to green)
- 7.22% blue
The +0.05 Offset
The +0.05 Offset
The formula adds 0.05 to both luminance values:This prevents division by zero for pure black (luminance 0) and ensures that the contrast ratio of white on black is exactly 21:1, which matches testing conditions used in WCAG research.
Visual Indicators
Theme Gen provides real-time feedback on accessibility:Toolbar Badges
Each color button displays a badge indicating its contrast status:- ✓ Pass - Meets or exceeds the required ratio (green indicator)
- ✓ Warn - Passes but below 1.5× the target (yellow indicator)
- ✗ Fail - Below the required ratio (red indicator)
Smart Shuffle Tooltip
When you hover over the Smart Shuffle button, a tooltip displays:- Overall pass rate (e.g., “5/5 passing”)
- Detailed breakdown of all contrast checks
- Color-coded ratios (green for pass, red for fail)
Smart Shuffle ensures all required checks pass before accepting a palette. It tries up to 24 different color combinations until it finds one that meets all accessibility requirements.
Automatic Contrast Adjustment
Theme Gen doesn’t just check contrast—it actively improves it:- Checks if the current color meets the minimum ratio
- If not, adjusts lightness in small steps (3% per step)
- Preserves hue and chroma—only lightness changes
- Stops as soon as the ratio is met
- Maximum of 25 steps (75% lightness change)
This approach maintains your color’s character while ensuring it’s accessible. The algorithm uses OKLCH color space, which provides perceptually uniform adjustments—a 3% change in lightness looks the same whether you’re adjusting a light color or a dark color.
Testing Your Theme
In Theme Gen
- Check the Toolbar Badges - All should show ✓ (checkmark)
- Hover Smart Shuffle - Should show “5/5 passing”
- Review Preview Components - Text should be crisp and easy to read
- Test Both Modes - Toggle light/dark and check both
External Tools
For additional validation, you can use:- WebAIM Contrast Checker - https://webaim.org/resources/contrastchecker/
- Color.review - https://color.review/
- Chrome DevTools - Built-in contrast checker in the color picker
Using Chrome DevTools
Using Chrome DevTools
- Right-click any text element and select “Inspect”
- In the Styles panel, click the color swatch next to
color - The color picker shows contrast ratios with AA/AAA indicators
- Adjust colors directly and see real-time contrast updates
Common Questions
Why are my colors being changed?
Why are my colors being changed?
If your colors don’t meet the required contrast ratios, Theme Gen automatically adjusts them. This only affects lightness—hue and saturation are preserved.To maintain exact colors, ensure they meet these requirements:
- Text/Background: 7:1
- Primary/Background: 3:1
- Text/Container: 4.5:1
- Accent/Container and Accent/Background: 3:1
Can I use lower contrast ratios?
Can I use lower contrast ratios?
Theme Gen enforces WCAG standards to ensure your themes are accessible. However, you can:
- Export your theme
- Manually adjust colors in your code
- Use CSS filters or opacity to reduce contrast
Why AAA for body text instead of AA?
Why AAA for body text instead of AA?
While WCAG AA (4.5:1) is the legal requirement, Theme Gen uses AAA (7:1) for body text because:
Do all colors need to be accessible?
Do all colors need to be accessible?
No. Only colors that appear together need sufficient contrast:
- ✓ Text on background must pass
- ✓ Buttons/links on background must pass
- ✗ Primary and accent don’t need contrast with each other
- ✗ Container and background don’t need contrast (unless text appears on both)
Resources
WCAG 2.1 Guidelines
Official WCAG quick reference guide
WebAIM Contrast Checker
Test specific color combinations
Creating Themes
Learn how to create accessible themes
Exporting Themes
Export your accessible theme for production