Skip to content
tezvyn:

How should you adapt animations for prefers-reduced-motion?

Source: developer.mozilla.orgHardHow cards are made

How should you adapt animations for prefers-reduced-motion?
Summary

Vestibular accessibility and media ergonomics.

Key points

Scope motion to no-preference, swap scaling for opacity or instant cuts, keep functional changes visible.

Watch out for

Ignoring the setting or using JS instead of CSS media features.

What's really being asked

This question probes whether you treat accessibility as a systems design problem rather than a checklist item. The interviewer wants to see that you understand vestibular motion disorders, know the specific CSS media feature, and can reason about which motion is decorative versus functional. Seniors should demonstrate they have built or audited design systems for reduced motion, not just read a blog post about it.

The full answer

First, name the feature explicitly: the prefers-reduced-motion CSS media feature. Second, explain that the correct pattern is usually to scope animations inside @media (prefers-reduced-motion: no-preference) so motion is opt-in rather than opt-out. Third, describe replacement strategies: swap scaling, parallax, or large panning animations with opacity fades, color shifts, or instant state changes. Fourth, preserve essential functional motion by making it instant rather than removing it entirely, for example a loading spinner should snap to its final state or be replaced by a static indicator so the user still knows the system is working. Fifth, mention testing on real operating system settings because the browser inherits the value from the OS and dev-tools emulation alone is insufficient for confidence.

The mistakes people make

A major red flag is saying you would ignore the preference because animations are decorative. Another is suggesting JavaScript sniffing or a user toggle instead of the native media feature, which breaks the contract between the OS and the browser. Candidates also stumble by proposing to disable all transitions including functional ones, leaving users without loading feedback or state change cues. Treating reduced motion as a performance optimization rather than an accessibility requirement signals a fundamental misunderstanding.

What usually comes next

The interviewer may ask how you would handle a complex WebGL or canvas animation that cannot be controlled by CSS media queries. They might also ask how a design token system should expose motion so product engineers do not accidentally ship vestibular triggers, or how you would write an ESLint or stylelint rule to enforce reduced-motion guards. Another variant is asking what you do when marketing insists on a hero video with motion.

A concrete example

Suppose a modal dialog enters with a scale and translate transition. In the default experience it scales from 0.95 to 1 and fades in over 200 milliseconds. Under @media (prefers-reduced-motion: reduce) you remove the transform and change the duration to 0 milliseconds so the dialog appears instantly, but you keep the backdrop opacity transition if it does not trigger vestibular issues, or replace it with an instant darkening. The trigger button still opens the modal, focus still moves, and the user gets identical functional outcomes without the motion.

Interview question

Which pattern best respects prefers-reduced-motion while preserving essential functional feedback?

  • a.Make decorative motion opt-in with the media feature and convert functional motion to instant state changes or static equivalentsCorrect
  • b.Strip out all CSS transitions and animations, including loading spinners and modal entrances, to ensure absolutely no motion occurs
  • c.Scope every animation inside @media (prefers-reduced-motion: no-preference) and suppress all visual changes when the preference is set to reduce
  • d.Use a JavaScript-based user toggle to let visitors opt out of animations independently of their OS-level preference
Why?

The correct strategy scopes decorative motion inside @media (prefers-reduced-motion: no-preference) so it is opt-in, while preserving functional cues by making them instant or replacing them with static indicators. Option C is tempting because wrapping in no-preference is correct for decorative motion, but suppressing all visual changes removes essential feedback like loading states.

Just read this? Test yourself on what you have been reading.

Read the original → developer.mozilla.org

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on css — each one lists the topics its interview covers.

See open roles