Skip to content

prefers-reduced-motion Not Respected Fix

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about prefers. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

Users with vestibular disorders, epilepsy, or motion sensitivity can experience discomfort or seizures from animations, parallax effects, and auto-playing content. The prefers-reduced-motion media query lets users request fewer animations, but many sites ignore it.

Quick Fix

Step 1: Use prefers-reduced-motion media query

/* Wrong — animations play regardless of user preference */
.card {
    transition: transform 0.3s ease;
}

.card:hover {
    transform: scale(1.05);
}

/* Right — respect user preference */
.card {
    transition: transform 0.3s ease;
}

.card:hover {
    transform: scale(1.05);
}

@media (prefers-reduced-motion: reduce) {
    .card {
        transition: none;
    }

    .card:hover {
        transform: none;
    }

    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

Step 2: Disable auto-playing animations

/* Wrong — auto-play animation does not respect preference */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.notification-dot {
    animation: pulse 2s ease infinite;
}

/* Right — disable when user prefers reduced motion */
.notification-dot {
    animation: pulse 2s ease infinite;
}

@media (prefers-reduced-motion: reduce) {
    .notification-dot {
        animation: none;
        /* Show static indicator instead */
        background: red;
    }
}

Step 3: Use JavaScript for granular control

// Wrong — JavaScript animations ignore user preference
function startParallax() {
    window.addEventListener('scroll', () => {
        const scrolled = window.pageYOffset;
        document.querySelector('.parallax-bg').style.transform =
            `translateY(${scrolled * 0.5}px)`;
    });
}

// Right — check preference before starting
const motionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');

function startParallax() {
    if (motionQuery.matches) return; // Do not start parallax

    window.addEventListener('scroll', () => {
        const scrolled = window.pageYOffset;
        document.querySelector('.parallax-bg').style.transform =
            `translateY(${scrolled * 0.5}px)`;
    });
}

// Also listen for changes
motionQuery.addEventListener('change', () => {
    if (motionQuery.matches) {
        // User enabled reduced motion — stop all animations
        stopAllAnimations();
    } else {
        // User disabled reduced motion — safe to animate
        enableAnimations();
    }
});

Step 4: Provide a manual toggle

<!-- Wrong — no way to disable animations manually -->
<div class="animated-background">
    <h1>Welcome</h1>
</div>

<!-- Right — provide a toggle button -->
<button
    id="motion-toggle"
    onclick="toggleAnimations()"
    aria-pressed="false"
>
    Disable animations
</button>

<script>
    function toggleAnimations() {
        const isDisabled = document.body.classList.toggle('reduce-motion');
        document.getElementById('motion-toggle').textContent =
            isDisabled ? 'Enable animations' : 'Disable animations';
        document.getElementById('motion-toggle').setAttribute('aria-pressed', isDisabled);
    }
</script>

Step 5: Make critical motion essential

/* Wrong — all animations removed, including essential ones */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Right — allow essential animations */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* Keep essential animations (e.g., loading spinner) */
    .essential-animation {
        animation-duration: inherit !important;
    }

    /* Prefer scroll-behavior: auto over smooth */
    html {
        scroll-behavior: auto;
    }
}

Prevention

  • Use prefers-reduced-motion: reduce to disable non-essential animations
  • Set global animation/transition to near-zero duration for reduced motion
  • Provide a manual toggle for users who want control beyond OS settings
  • Test with prefers-reduced-motion: reduce enabled in DevTools
  • Keep only essential animations (loading, progress indicators)

Common Mistakes with reduced motion

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

These mistakes appear frequently in real-world A11Y code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### How do I enable prefers-reduced-motion in DevTools?

Chrome DevTools: Rendering tab > Emulate CSS media feature > prefers-reduced-motion: reduce. Firefox: Responsive Design Mode > More options > prefers-reduced-motion: reduce. Safari: Develop > Experimental Features > prefers-reduced-motion.

What animations are considered essential?

Loading spinners, progress bars, and collapse/expand transitions for accordion menus are essential. Decorative animations (parallax, confetti, floating elements, pulsing effects) are non-essential and should be disabled.

Does prefers-reduced-motion affect JavaScript-based animations?

Yes, but only if your code checks for it. JavaScript-based animations (requestAnimationFrame, CSS-in-JS, GSAP) need explicit checks against window.matchMedia('(prefers-reduced-motion: reduce)') to respect the user preference.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro