useReduceMotion
React and React Native
A React Native hook that reports whether the system asks to reduce motion and follows later changes.
Whether the person has asked the system to reduce motion. It reads the setting once on mount and follows later changes, so animated components can skip or shorten their motion. It starts as false until the platform answers. Works in React and in React Native with no extra packages.
Installation
CLI
npx @modus-ui/cli add use-reduce-motionManual
- Copy the code from the code tab, using the React or React Native switch for your project.
- Create a file at
components/ui/use-reduce-motion.ts. - Paste the code.
The CLI installs the React Native version in an Expo or React Native app and the React version everywhere else. In a project that targets both, keep the React file use-reduce-motion.ts and the React Native file use-reduce-motion.native.ts side by side and import ./use-reduce-motion; Metro picks the .native file on its own.
Usage
tsx
API
| Part | Type | Description |
|---|---|---|
| Returns | boolean | True when the system asks to reduce motion. |
Comments