Learning Tips | Published Nov 17, 2026 | 8 min read

CSS prefers-reduced-motion: Respect Motion Preferences

Learn to use CSS prefers-reduced-motion, adapt JavaScript animations, preserve interaction feedback, and test accessible reduced-motion experiences.

Diagram contrasts a default sliding panel with a reduced-motion version that keeps the panel visible and state feedback clear

The CSS prefers-reduced-motion media feature lets a page respect a user’s operating-system motion preference. Learn how to reduce non-essential animation without removing feedback, preserve function, and test both motion modes.

Motion can help explain state changes, but large or repeated movement can cause discomfort for some people. Users can enable an operating-system preference to reduce motion. CSS exposes that preference through prefers-reduced-motion, allowing developers to adapt transitions and animation without asking users to find a site-specific toggle.

Respect the preference in CSS

The feature has two values: no-preference and reduce. Keep the normal experience as the default, then override non-essential effects for the reduced preference.

.panel {
  transition: transform 220ms ease, opacity 220ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .panel {
    transition: opacity 120ms linear;
  }

  .decorative-motion {
    animation: none;
  }
}

Prefer disabling or shortening large spatial movement, parallax, auto-scrolling, and looping decorative animation. Small opacity or color changes may be acceptable for some interfaces, but test them and avoid assuming every reduced-motion user wants the same effect. A media query is a way to honor the preference, not a guarantee that a particular animation is harmless.

Preserve interaction and state feedback

Removing motion should not hide information or break an interaction. If a panel slides into view in the default mode, it still needs to appear in reduced-motion mode. If an animation communicates loading or progress, provide another clear status indication. Keep focus behavior, control availability, and state changes consistent.

When animation is triggered by interaction and is not essential to function or information, WCAG 2.3.3 says it can be disabled. This criterion is Level AAA. Other motion-related criteria address different situations, so do not treat this one success criterion as a complete motion-accessibility checklist.

Handle JavaScript animation too

CSS rules do not automatically stop animations created through JavaScript APIs or canvas. Read the media preference and adapt the behavior. If the preference changes while the page is open, respond to the media query change event.

const motionPreference = matchMedia(
  "(prefers-reduced-motion: reduce)"
);

function updateMotionMode() {
  if (motionPreference.matches) {
    stopDecorativeAnimation();
  } else {
    startDecorativeAnimation();
  }
}

updateMotionMode();
motionPreference.addEventListener("change", updateMotionMode);

Use the actual animation library’s pause or cancellation API when available. Ensure cleanup removes listeners when a component is destroyed. Avoid setting a global “all animations off” rule that accidentally removes important feedback or leaves elements in an unusable intermediate state.

Offer controls for motion that starts automatically

For automatically moving or updating content, consider whether users need a pause, stop, or hide control in addition to honoring reduced-motion preference. The right requirement depends on the type, duration, and purpose of the movement. A preference query helps tailor the initial presentation, but an in-page control gives users agency when preferences are unavailable or when they want to change motion locally.

Test both modes and real interactions

  • Enable reduced motion in the operating system and confirm the browser reports the preference.
  • Test with the preference unset as well as set to reduce.
  • Check hover, focus, expand/collapse, route changes, loading, and error feedback.
  • Verify JavaScript-driven animations and dynamically mounted components respond too.
  • Confirm reduced motion does not hide content, trap focus, or make state changes ambiguous.

Respecting reduced motion is more than shortening a transition. Identify which movement is decorative, preserve the information and interaction it once conveyed, and test the whole experience with the user preference enabled.

Want a structured Java learning path?

Explore Jaipur Engineers course options to connect Java fundamentals, debugging, backend development and project practice in a guided learning plan.

Explore the Java program   Ask for course guidance