R
fn

usePreferredReducedMotion

v0.0.15testeddemo

Reactive `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

ParameterTypeDescription
options?UseMediaQueryOptionsOptions (custom `window`)

Returns

UsePreferredReducedMotionReturnReadonly ref of the current motion preference