Most sites handle reduced motion with one CSS rule. beUI's site has it too:
@media ( prefers-reduced-motion : reduce ) { * , * : : before , * : : after { animation-duration : 0.01ms ! important ; transition-duration : 0.01ms ! important ; } }
Enter fullscreen mode
Exit fullscreen mode
It's worth having, but on a Framer Motion site it isn't enough. Turn on "Reduce motion" with only this rule in place, and drawers still slide in, tabs still spring and counters still roll.
That CSS only shortens CSS animations and transitions. Framer Motion works out each frame of a spring in JavaScript and writes the result to the element's style, so the media query never sees it.
I build beUI , a library of animated React components, and more than 150 of its files now read the reduced motion setting. Here's what I learned doing that.
Start with the hook, and handle null
import { useReducedMotion } from "motion/react" ;
const reduce = useReducedMotion ( ) ??…