Skip to content
Design System
GitHub

usePrefersReducedMotion

v0.53.0, changelog

Whether the person asked for less motion: prefersReducedMotion() read now, for a handler, and usePrefersReducedMotion() followed while mounted.

Install
npx shadcn add @syncrobotic/use-reduced-motion

Overview

When to use

  • Motion driven from JavaScript: a scroll into view, a canvas camera, a spring.
  • Turning off a loop that only decorates.

Use something else

  • CSS animations: the kit's motion tokens already follow prefers-reduced-motion.

Usage rules

  • usePrefersReducedMotion() while mounted, prefersReducedMotion() in a handler. Under reduced motion only opacity changes and loops stop.
  • CSS animations in the kit already follow the media query; use it for motion driven from JavaScript (a scroll, a canvas, a spring).

API

What the file exports. The source is in the Source sheet above.

prefersReducedMotion(fallback = false): boolean
Whether the person asked for less motion, read now: for a handler or an effect deciding whether to glide or jump (a scroll, a camera fly-to).
useMediaQuery(query: string, fallback = false): boolean
Whether a CSS media query matches, followed while mounted.
usePrefersReducedMotion(): boolean
Whether the person asked for less motion: prefersReducedMotion() read now, for a handler, and usePrefersReducedMotion() followed while mounted.

Changelog

  • 0.53.02026-11-27Its doc opens with its description, word for word; the code is unchanged.
  • 0.52.02026-11-27Adds useMediaQuery, shared by the components that listened to media queries themselves.
  • 0.51.02026-11-27Stable: its API is a standard one the kit styles, unchanged for ten releases, with unit tests. It changes only in a major release from here.

How to upgrade