useReducedMotion
The useReducedMotion hook reports whether the user asked their operating system to reduce motion (prefers-reduced-motion: reduce). Use it to turn off or simplify animations for people who are sensitive to movement.
Usage
Installation
import { useReducedMotion } from "hookstorm";
Parameters
This hook does not take any parameters.
Return Values
A boolean — true if the user prefers reduced motion, false otherwise.
Example Usage
import { ReactElement } from "react";
import { useReducedMotion } from "hookstorm";
export default function Banner(): ReactElement {
const reduceMotion = useReducedMotion();
return (
<div
style={{
transition: reduceMotion ? "none" : "transform 300ms ease",
}}
>
{reduceMotion ? "Animations are off" : "Animations are on"}
</div>
);
}
Notes
- The value updates live when the user changes the OS setting.
- SSR-safe: returns
falseon the server and reads the real value after mounting. - This is a focused wrapper around
useMediaQueryfor the most common accessibility query.