fn
usePreferredReducedMotion
v0.0.15testeddemoReactive `prefers-reduced-motion` media query, resolving to `'reduce'` when the user requests reduced motion and `'no-preference'` otherwise. SSR-safe via {@link useMediaQuery}.
Examples
ts
const motion = usePreferredReducedMotion();
// motion.value === 'reduce' | 'no-preference'ts
watchEffect(() => {
transitionDuration.value = motion.value === 'reduce' ? 0 : 200;
});Demo
Loading demo…
Signature
ts
export function usePreferredReducedMotion(
options: UsePreferredReducedMotionOptions ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
options? | UseMediaQueryOptions | Options (custom `window`) |
Returns
UsePreferredReducedMotionReturnReadonly ref of the current motion preference