useReducedMotion
Browser & deviceTrack the user's reduced-motion preference (prefers-reduced-motion)
Install
$ npm install @usefy/use-reduced-motionQuick start
useReducedMotion.tsx
import { useReducedMotion } from "@usefy/use-reduced-motion";
const reduced = useReducedMotion();
<div style={{ transition: reduced ? "none" : "transform 300ms" }} />;API reference
useReducedMotion(options?): boolean
options.defaultValue— value returned on the server / whenmatchMediais unavailable (defaultfalse).options.initializeWithValue— whentrue(default), the real preference is read synchronously on the first client render. Set tofalseto renderdefaultValueon the first client render and defer the real read to a post-commit effect, avoiding a hydration mismatch when the server rendereddefaultValue.
Go deeper
This page is the quick reference. For every example, prop, and edge case, read the full README — or open Storybook to change props live.