Respecting prefers-reduced-motion
prefers-reduced-motion is a CSS media feature that reports whether a visitor has asked their device for less motion. It has two values, no-preference and reduce. Wrap large movement such as parallax, zooms and slides in a query, and when the value is reduce, swap them for a short fade or no animation.
| System | Setting |
|---|---|
| Windows 11 | Settings > Accessibility > Visual effects > Animation effects (off) |
| macOS | System Settings > Accessibility > Display (or Motion) > Reduce motion |
| iOS | Settings > Accessibility > Motion > Reduce Motion |
| Android 9 and later | Settings > Accessibility > Remove animations |
| Firefox (testing) | about:config, set ui.prefersReducedMotion to 1 |
Updated
People turn on reduced motion because sliding, zooming and parallax can trigger dizziness, nausea or headaches, especially for those with vestibular disorders. The badge below reads your own device setting live, and the demo shows the same animation in full and reduced form, so you can compare before choosing a pattern.
Your motion setting
The badge reads your device setting with matchMedia, and the preview switch shows the reduced animation without changing your system.
CSS patterns
Motion as an enhancement
The card slides in only when no preference is set. Everyone else sees a gentle fade.
<style>
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slide-up { from { opacity: 0; transform: translateY(40px) } to { opacity: 1; transform: none } }
.card { padding: 20px; border-radius: 12px; background: #eff6ff; animation: fade 400ms ease both }
@media (prefers-reduced-motion: no-preference) {
.card { animation: slide-up 600ms cubic-bezier(.2,.8,.2,1) both }
}
</style>
<div class="card">This card arrives with motion only if your device allows it.</div>A safety net for existing sites
Useful when you cannot rewrite every animation. Durations become almost zero rather than none, so animationend and transitionend events still fire.
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}JavaScript and React
Read the setting and follow changes
matchMedia returns a live list. Its change event fires when the visitor flips the setting.
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
function scrollToTop() {
window.scrollTo({ top: 0, behavior: query.matches ? "auto" : "smooth" });
}
query.addEventListener("change", (event) => {
document.documentElement.dataset.motion = event.matches ? "reduce" : "full";
});React hook: usePrefersReducedMotion
Starts at true on the server so nothing animates before the browser has answered.
import { useEffect, useState } from "react";
const QUERY = "(prefers-reduced-motion: reduce)";
export function usePrefersReducedMotion() {
const [reduce, setReduce] = useState(true);
useEffect(() => {
const mql = window.matchMedia(QUERY);
setReduce(mql.matches);
const onChange = (e) => setReduce(e.matches);
mql.addEventListener("change", onChange);
return () => mql.removeEventListener("change", onChange);
}, []);
return reduce;
}What to swap each effect for
| Full motion | Reduced version |
|---|---|
| Parallax background | Static background |
| Slide or zoom page change | Cross-fade, or an instant change |
| Element flies in on scroll | Short fade in place |
| Spinning loader | Pulsing opacity or a progress bar |
| Smooth scroll to anchor | Instant jump |
| Autoplaying background video | Poster image with a play button |
Which motion causes problems
The trouble is movement that fills a large part of the view or moves in a direction the visitor did not cause: parallax backgrounds, full-page zooms, sliding page changes, spinning elements and content that jumps as you scroll.
Small, quick, user-started feedback, such as a button colour change or a checkbox tick, is rarely an issue and can usually stay.
No-motion-first CSS
Many sites add a reduce query at the end that sets every duration to almost zero. It works, but it is easy to miss one animation, and some scripts listen for animationend events that then fire instantly.
Writing the motion inside a no-preference query flips the default. Anyone whose browser does not report a preference still gets motion, and anything you forget falls back to the calm version.
Scripts and libraries
CSS queries do not reach animations started from JavaScript, canvas or smooth scrolling calls. Check the media query before calling element.animate() or scrollIntoView with behavior: smooth.
Read the setting once at start and subscribe to its change event, so a person who switches it mid-visit is respected without a reload.
How it works
- Check the badge: it shows what your device reports right now and updates if you change the setting.
- Use the preview switch to see the reduced version of the demo without changing your system setting.
- Copy the CSS, JavaScript or React pattern that matches how your site animates.
Tips
- Reduce, do not remove. A quick opacity fade still shows that something changed without moving across the screen.
- Write motion as the enhancement: put animations inside @media (prefers-reduced-motion: no-preference) so the safe version is the default.
- Autoplaying video and carousels need a pause control as well, whatever the motion setting says.
- In Chrome DevTools you can emulate the setting from the Rendering panel to test without changing your system.
- Scroll-triggered effects count too. Large parallax and scroll-jacking are the most common complaints.
Frequently asked questions
What values does prefers-reduced-motion have?
Two: no-preference, when the visitor has not set anything, and reduce, when they have asked for less motion. Writing @media (prefers-reduced-motion) on its own is the same as asking for reduce.
How do I check prefers-reduced-motion in JavaScript?
Call window.matchMedia("(prefers-reduced-motion: reduce)") and read its matches property. Add a change event listener to the returned object to react when the setting changes while the page is open.
Should I turn off every animation when reduce is set?
No. The request is for less motion, not a frozen page. Keep colour changes, short fades and progress indicators, and remove or shrink movement such as sliding, scaling, spinning and parallax.
Is respecting reduced motion required by WCAG?
WCAG 2.3.3 Animation from Interactions, level AAA, asks that motion triggered by interaction can be turned off unless it is essential. Respecting the system setting is one of the listed ways to meet it. Separately, 2.2.2 Pause, Stop, Hide at level A covers motion that starts on its own.
How do I handle reduced motion in Tailwind?
Use the motion-safe: variant to apply an animation only when no preference is set, or motion-reduce: to override one when reduce is set, for example motion-safe:animate-bounce.
Related: CSS transitions playground, Scroll animations, Framer Motion examples, CSS media queries, Website accessibility checklist, CSS animation generator.
Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.
More in Guides
- How to Build a Print-on-Demand Website
- Ecommerce Product Page Design: Anatomy and Examples
- How to Turn Your Website into a Progressive Web App
- Public Library Website Accessibility: Catalogs, Event Calendars and the Vendors Behind Them | How-to Guide
- Rate Limiting: How It Works, With a Live Simulator
- React Chart Libraries Compared: One Chart, Six Libraries
- React Cookie Consent: A Banner That Actually Blocks Scripts
- React Drag and Drop: Sortable List and Kanban Board
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App