What is prefers-reduced-motion and why should I use it?
Some people feel dizzy or uncomfortable with a lot of motion, and turn on "reduce motion" in their device settings. The browser tells your site about that setting, and you tone the motion down or remove it.
Steps
- Write a media query: prefers-reduced-motion: reduce.
- Inside it, stop large motion (movement, zoom, parallax, endless loops).
- Keep gentle changes like opacity if needed, or show the final state straight away.
- In JavaScript, check the setting with matchMedia before starting any motion.
- Test it: turn on "Reduce motion" in your operating system and reload your page.
The code
CSS
.card { animation: float 4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
.card { animation: none; }
}JavaScript
const reduce = window.matchMedia('(prefers-reduced-motion: reduce)');
function start() { if (!reduce.matches) { /* run animation */ } }
start();
reduce.addEventListener('change', start);Note: WCAG covers pausing moving content (Success Criterion 2.2.2) and disabling interaction-triggered motion (2.3.3).
Tahrikit motions are written to respect this setting.