1. What prefers-reduced-motion actually asks for
macOS, iOS, Windows, Android and most Linux desktops have a setting that reduces interface motion. Browsers expose it through the prefers-reduced-motion media feature, which is either no-preference or reduce.
Reduce does not mean no animation at all. It means avoid motion that moves things across the screen, zooms, parallax-scrolls or loops forever. Colour and opacity changes, and the information an animation carries, should stay.
- Remove: parallax, 3D tilt, auto-playing carousels, large slide-ins, background loops.
- Shorten or swap for a fade: page transitions, modal entrances, list reordering.
- Keep: progress indicators (as static or stepped progress), focus rings, colour changes on state.
2. Handle it in CSS first
If an animation is defined in CSS, disable or replace it in CSS. This works before any JavaScript loads and keeps server-rendered pages correct on first paint.
.card-enter {
animation: slide-up 400ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slide-up {
from { opacity: 0; transform: translateY(24px); }
to { opacity: 1; transform: none; }
}
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.card-enter {
animation: fade-in 150ms linear;
}
}3. A React hook that stays in sync
JavaScript animations (springs, requestAnimationFrame loops, canvas) need the value in code. Reading matchMedia once is not enough, because users can change the setting while the page is open. useSyncExternalStore subscribes to the media query and returns a server snapshot, so it is safe in Next.js server rendering.
import { useSyncExternalStore } from "react";
const QUERY = "(prefers-reduced-motion: reduce)";
function subscribe(onChange: () => void) {
const mql = window.matchMedia(QUERY);
mql.addEventListener("change", onChange);
return () => mql.removeEventListener("change", onChange);
}
function getSnapshot() {
return window.matchMedia(QUERY).matches;
}
function getServerSnapshot() {
return false; // the server cannot know; the client corrects it after hydration
}
export function usePrefersReducedMotion() {
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
}4. Use it to change behaviour, not to hide content
With the flag in hand, jump straight to the end state instead of animating toward it. The content and the result of the interaction stay the same; only the path between states changes.
import { useEffect, useState } from "react";
import { usePrefersReducedMotion } from "./usePrefersReducedMotion";
export function Reveal({ children }: { children: React.ReactNode }) {
const reduced = usePrefersReducedMotion();
const [shown, setShown] = useState(false);
useEffect(() => {
const id = requestAnimationFrame(() => setShown(true));
return () => cancelAnimationFrame(id);
}, []);
return (
<div
style={{
opacity: shown ? 1 : 0,
transform: shown || reduced ? "none" : "translateY(16px)",
transition: reduced ? "opacity 150ms linear" : "opacity 300ms ease-out, transform 300ms ease-out",
}}
>
{children}
</div>
);
}5. How Kipluo components handle it
Every Kipluo component reads reduced motion through prefersReducedMotion() from @kipluo/core. It checks the media query and also honours data-motion="reduced" or data-motion="full" on the <html> element, which is the in-app switch described above.
With reduced motion on, springs jump to their target and loaders stop looping while still showing progress. The free Tilt Card turns its 3D tilt off entirely, because tilt is purely decorative motion.
// npx kipluo add tilt-card
import { TiltCard } from "@/components/kipluo/tilt-card";
export function MotionSwitch() {
return (
<button
type="button"
onClick={() => {
const root = document.documentElement;
root.dataset.motion = root.dataset.motion === "reduced" ? "full" : "reduced";
}}
>
Toggle reduced motion
</button>
);
}
export function Pricing() {
return (
<TiltCard maxTilt={10}>
<h3>Personal</h3>
<p>$29, one payment</p>
</TiltCard>
);
}Accessibility checklist
Tick each one off as you check your build. Your ticks stay in this browser.
0 of 4 checked
Build it yourself or install it
Build it yourself when
You have a few CSS animations. A media query block per animation and the hook above cover them.
Install Kipluo when
You want every spring, gesture and loader to follow the OS setting and an in-app data-motion override without wiring each one.