fn

usePreferredReducedMotion

v0.0.14testeddemo

Reactive prefers-reduced-motion media query, resolving to 'reduce' when the user requests reduced motion and 'no-preference' otherwise. SSR-safe via 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?UsePreferredReducedMotionOptionsOptions (custom window)

Returns

UsePreferredReducedMotionReturnReadonly ref of the current motion preference