Preferences and Themes
How Vanilla Breeze follows the reader's system settings for motion, contrast, transparency and forced colors, and the three accessibility themes you can offer.
System preferences
Readers set these once in their operating system or browser. The library reads them with media queries and needs nothing from you.
| Preference |
Media query |
What changes |
| Reduce motion |
prefers-reduced-motion: reduce |
Every duration token becomes 0ms, so transitions built on the tokens end at once. Smooth scrolling is turned off. Components that animate on their own, such as carousels and tickers, stop. |
| Increase contrast |
prefers-contrast: more |
Muted text and borders darken, and the focus ring widens to 3px. |
| Reduce transparency |
prefers-reduced-transparency: reduce |
Translucent and blurred surfaces become solid. |
| Forced colors |
forced-colors: active |
The browser replaces every color with the reader's palette. The library adds borders and outlines where a shape was drawn with background color alone, so controls and states stay visible. |
| Dark or light |
prefers-color-scheme |
Every color token has a light and a dark value. See Themes. |
Motion
Motion in the library is written against duration tokens. That makes reduced motion one rule and not one per component, and it covers your own CSS when you use the same tokens.
.panel { transition: opacity var(--duration-normal) var(--ease-default);} @media (prefers-reduced-motion: reduce) { :root { --duration-fast: 0ms; --duration-normal: 0ms; --duration-slow: 0ms; }}
A site can also offer its own switch. Put data-motion-reduced on <html> and the same tokens go to zero whatever the system says. <settings-panel> writes that attribute and remembers the choice.
For an animation that does not use the tokens, write the query yourself and remove the movement, keeping any change of state the reader needs to see.
Accessibility themes
Three themes are opt-in, for readers who want more than the defaults. Each is a token in data-theme, and they combine with each other and with any other theme.
| Theme |
Token |
What it changes |
| High contrast |
a11y-high-contrast |
Text at 7:1 or better against its surface (WCAG AAA), darker borders, a 3px focus ring, no shadows |
| Large text |
a11y-large-text |
Base text 25% larger, controls at least 44px, more space between elements |
| Dyslexia-friendly |
a11y-dyslexia |
Atkinson Hyperlegible, wider letter and word spacing, taller lines, shorter measure, no justified text |
<html data-theme="a11y-high-contrast"> <html data-theme="forest a11y-high-contrast a11y-large-text">
The typeface for the dyslexia-friendly theme is served with the library and downloads only when the theme is in use.
Letting readers choose
<settings-panel> gives readers the three themes, light and dark mode and a reduced motion switch, and stores what they pick. This site uses it: open the gear button at the corner of the page.
<settings-panel></settings-panel>
If you build your own control, set the tokens on <html> as the demo above does. Treat a stored choice as an addition to the system preference, never as a replacement for it.
Color
The semantic color tokens are tested for AA contrast against the surfaces they are meant for: 4.5:1 for text, 3:1 for large text and for the edges of controls. That holds while you stay on the tokens.
color: var(--color-text); color: var(--color-text-muted);
Two things stay with you. Check the contrast of any color you introduce. And where color carries meaning, add a second cue: an icon, a word or a shape. The library's own states do this. An invalid field has a message as well as a red border, and a link in running text is underlined as well as colored.