principlejavascriptMajor
Respecting prefers-reduced-motion for Accessible Animations
Viewed 0 times
prefers-reduced-motionaccessible animationvestibular disorderWCAG 2.3.3reduced motionuseReducedMotion
Problem
Animations can trigger vestibular disorders and migraines for users who have requested reduced motion via their OS settings.
Solution
Check
prefers-reduced-motion in both CSS and JavaScript, and either remove or reduce animations for these users./* Wrap all non-essential animations */
@media (prefers-reduced-motion: no-preference) {
.card {
animation: fadeInUp 0.4s ease forwards;
transition: transform 0.2s ease;
}
}
/* Global kill-switch variant */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}// Framer Motion
import { useReducedMotion } from 'framer-motion';
function AnimatedCard() {
const reduceMotion = useReducedMotion();
return (
<motion.div
initial={{ opacity: 0, y: reduceMotion ? 0 : 20 }}
animate={{ opacity: 1, y: 0 }}
/>
);
}
// Vanilla JS
const mq = window.matchMedia('(prefers-reduced-motion: reduce)');
if (!mq.matches) { runAnimation(); }Why
WCAG 2.1 Success Criterion 2.3.3 (Level AAA) requires a mechanism to disable motion animation unless it is essential. Ignoring reduced motion can cause real medical harm for users with vestibular disorders.
Gotchas
- Do not completely hide content when reducing motion — replace animated reveals with instant visibility.
- Essential animations (progress bars, loading spinners) should still work; only decorative motion should be removed.
prefers-reduced-motion: reduceis the active opt-in;no-preferencemeans the user has not expressed a preference.- Test by toggling the OS setting (macOS: Accessibility > Display > Reduce Motion).
Revisions (0)
No revisions yet.