accessible-animation
iart-ai/web-animation-skills
Respect prefers-reduced-motion with tiered degradation, not all-or-nothing disabling.
What is accessible-animation?
Implements accessible animation patterns that honor the OS-level prefers-reduced-motion setting without removing all motion. Use when adding animations to web UIs, integrating animation libraries (GSAP, Framer Motion, Lenis), or addressing vestibular/motion-sickness accessibility issues.
- Tier animations into three categories: remove vestibular triggers (parallax, large-area slides, 3D rotation), soften non-essential motion (replace with short opacity fades), and preserve essential transitions (focus rings, loading indicators)
- Provide CSS media-query patterns with global safety nets and targeted overrides to gate motion libraries
- Offer JavaScript utilities (matchMedia gating, live change listeners) for JS-driven animation libraries like GSAP, Framer Motion, and Lenis
- Include a reusable React useReducedMotion hook with SSR-safe hydration handling
- Map to WCAG 2.3.3 (Animation from Interactions), C39 (CSS technique), and 2.2.2 (Pause, Stop, Hide) compliance
How to install accessible-animation
npx skills add https://github.com/iart-ai/web-animation-skills --skill accessible-animationHow to use accessible-animation
- 1.Identify all animations in your UI and sort them into three tiers: vestibular triggers (remove), non-essential motion (soften to short fades), and essential transitions (keep)
- 2.Add a global CSS safety net under @media (prefers-reduced-motion: reduce) to neutralize runaway motion with 0.01ms durations
- 3.Layer targeted CSS overrides to implement tiered degradation for each component
- 4.For JS-driven animation, use matchMedia('(prefers-reduced-motion: reduce)') to conditionally gate GSAP, Framer Motion, or Lenis instantiation
- 5.In React, use the provided useReducedMotion hook to conditionally set animation parameters (initial state, transition duration) in motion components
- 6.Test both the normal and reduced-motion paths by toggling the OS setting (macOS: Settings > Accessibility > Display > Reduce motion; Windows: Settings > Accessibility > Visual effects) and verify tiering is correct
Use cases
- Auditing and fixing animations in existing web UIs that trigger motion sickness or vestibular responses
- Gating GSAP timelines or Framer Motion animations to disable parallax and large-area slides while keeping opacity transitions
- Disabling Lenis smooth-scroll hijacking or scroll-jacked pinned scenes when reduced motion is preferred
- Building accessible carousels and marquees that respect the prefers-reduced-motion setting
- Ensuring focus-ring and loading-spinner animations remain visible and functional under reduced-motion constraints
- Web developers building accessible animation systems
- Teams integrating animation libraries (GSAP, Framer Motion, Anime.js, Lenis) into products
- Accessibility auditors and WCAG compliance specialists
- React developers needing a useReducedMotion hook for component-level motion gating
accessible-animation FAQ
No. Removing all animation is an over-correction that can be more disorienting (elements teleport) and removes useful affordances. Instead, tier animations: remove vestibular triggers (parallax, large-area slides, 3D rotation), soften non-essential motion (replace with short opacity fades ≤200ms), and keep essential transitions (focus rings, loading indicators).
Setting animation-duration or transition-duration to 0s can break JavaScript that waits for transitionend or animationend events. Using 0.01ms is fast enough to be imperceptible but allows event listeners to fire correctly.
Use GSAP's built-in matchMedia() API to conditionally set up timelines. Check the motionOK condition and apply Tier 1 animations (e.g., y: 80 moves) only when allowed; otherwise use Tier 2 (e.g., opacity fades). GSAP automatically reverts conditional setups when the OS setting changes.
Check prefersReducedMotion() before instantiating Lenis. Only create the Lenis instance and start its RAF loop if the function returns false. Users who toggle the OS setting will need to reload the page for the change to take effect.
prefers-reduced-motion: reduce is set when the user has enabled the OS-level reduced-motion setting. prefers-reduced-motion: no-preference (or the absence of the reduce query) means the user has not enabled it. Use no-preference to opt elaborate animations IN only when safe, which is the safest pattern.
Full instructions (SKILL.md)
Source of truth, from iart-ai/web-animation-skills.
name: accessible-animation description: This skill should be used when the user asks to "respect prefers-reduced-motion", "honor reduced motion", "make my animations accessible", "fix vestibular / motion-sickness issues", "add a useReducedMotion hook", "gate GSAP / Framer Motion / Lenis for reduced motion", or "meet WCAG 2.3.3 / C39". Provides tiered (not all-or-nothing) reduced-motion patterns in CSS and JS. version: 0.1.0
Accessible Animation (Reduced Motion, Tiered)
Honor prefers-reduced-motion: reduce as a graceful degradation, not a kill switch. The OS-level setting (macOS: Settings > Accessibility > Display > Reduce motion; Windows: Settings > Accessibility > Visual effects > Animation effects; iOS/Android equivalents) signals that vestibular-triggering motion causes nausea, dizziness, or migraines. The correct response is to remove the dangerous motion while keeping orientation cues.
When to use
Use when adding or auditing animation in a web UI, when a user reports motion sickness or WCAG findings, or when integrating animation libraries (GSAP, Framer Motion, Lenis smooth scroll, Anime.js, CSS keyframes) into an accessible product.
The core principle: tier motion, do not nuke it
Removing all animation is a common over-correction. An instant state change with no transition can be more disorienting (elements teleport) and removes useful affordances (focus rings, loading spinners that communicate progress). Sort every animation into three tiers:
- Tier 1 — Remove entirely (vestibular triggers). Parallax; large-area slides/translates across the viewport; scale/zoom of large elements; 3D rotation and spin; continuous auto-playing carousels and marquees; smooth-scroll hijacking (Lenis/Locomotive); scroll-jacked pinned scenes; motion-path animation; anything that moves a large portion of the screen or implies depth/self-motion.
- Tier 2 — Soften / shorten. Replace movement with a short opacity fade (≤200ms). Reduce distance and duration. Keep the fact of a transition (so elements don't teleport) but strip the displacement. Replace a 600ms slide-in-from-left with a 150ms cross-fade.
- Tier 3 — Always keep. Opacity fades, color/background transitions, focus-ring transitions, loading indicators, and motion that is essential to meaning (WCAG allows essential animation). These rarely trigger vestibular responses because they imply no self-motion.
CSS layer: media-query gating
Write motion as the default, then override under the reduce query. Prefer a global safety net plus targeted overrides.
/* Global safety net: neutralize runaway motion but DO NOT set 0s blindly,
which can break JS that waits for transitionend/animationend. Use 0.01ms. */
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important; /* stop infinite spins/marquees */
transition-duration: 0.01ms !important;
scroll-behavior: auto !important; /* kill smooth scroll */
}
}
The global net is a backstop. Layer intentional, tiered overrides on top so Tier 3 motion survives:
.card {
transition: transform 400ms ease, opacity 400ms ease, background-color 200ms ease;
}
@media (prefers-reduced-motion: reduce) {
.card {
/* Tier 2: drop the transform (movement), keep opacity + color (Tier 3) */
transition: opacity 150ms ease, background-color 150ms ease;
}
.parallax-layer { transform: none !important; } /* Tier 1: remove */
.hero-zoom { animation: none !important; } /* Tier 1: remove */
}
Use the positive query (prefers-reduced-motion: no-preference) to opt motion IN, which is the safest pattern for elaborate effects:
.hero { opacity: 1; } /* visible, static by default */
@media (prefers-reduced-motion: no-preference) {
.hero { animation: zoom-in 1.2s ease both; } /* only animate when allowed */
}
JS layer: matchMedia gating
CSS cannot gate JS-driven animation (GSAP timelines, Framer's animate, canvas/WebGL, Lenis). Read the same signal via matchMedia and react to live changes (users toggle the OS setting without reloading).
const REDUCE_QUERY = '(prefers-reduced-motion: reduce)';
export function prefersReducedMotion() {
return typeof window !== 'undefined'
&& window.matchMedia
&& window.matchMedia(REDUCE_QUERY).matches;
}
// Live updates: listen so toggling the OS setting takes effect immediately.
export function onReducedMotionChange(cb) {
const mq = window.matchMedia(REDUCE_QUERY);
const handler = (e) => cb(e.matches);
mq.addEventListener('change', handler); // modern API
return () => mq.removeEventListener('change', handler);
}
Library gating, applied as one reusable layer
// GSAP — use matchMedia(): GSAP reverts conditional setups on change.
import gsap from 'gsap';
const mm = gsap.matchMedia();
mm.add({
motionOK: '(prefers-reduced-motion: no-preference)',
motionReduce: '(prefers-reduced-motion: reduce)',
}, (ctx) => {
const { motionOK } = ctx.conditions;
if (motionOK) {
gsap.from('.hero', { y: 80, opacity: 0, duration: 1 }); // Tier 1 move
} else {
gsap.from('.hero', { opacity: 0, duration: 0.15 }); // Tier 2 fade
}
});
// Lenis smooth scroll — do not instantiate at all when reduced.
import Lenis from 'lenis';
let lenis = null;
if (!prefersReducedMotion()) {
lenis = new Lenis();
const raf = (t) => { lenis.raf(t); requestAnimationFrame(raf); };
requestAnimationFrame(raf);
}
React: a useReducedMotion hook
import { useState, useEffect } from 'react';
export function useReducedMotion() {
const query = '(prefers-reduced-motion: reduce)';
const get = () =>
typeof window !== 'undefined' && window.matchMedia
? window.matchMedia(query).matches
: false;
const [reduced, setReduced] = useState(get);
useEffect(() => {
const mq = window.matchMedia(query);
const onChange = () => setReduced(mq.matches);
onChange(); // sync after hydration
mq.addEventListener('change', onChange);
return () => mq.removeEventListener('change', onChange);
}, []);
return reduced;
}
// Framer Motion has its own useReducedMotion(); the hook above also works.
import { motion } from 'framer-motion';
function Card() {
const reduced = useReducedMotion();
return (
<motion.div
initial={reduced ? { opacity: 0 } : { opacity: 0, y: 40 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: reduced ? 0.15 : 0.5 }}
/>
);
}
Initialize SSR-rendered state to false (motion) and re-sync in useEffect to avoid a hydration mismatch; the OS value is only known client-side.
WCAG mapping
- 2.3.3 Animation from Interactions (AAA). Motion triggered by interaction (scroll, hover) must be disable-able unless essential. Honoring
prefers-reduced-motionis the standard technique. - C39 (CSS technique). Use the
prefers-reduced-motionquery to prevent motion. This is the named sufficient technique. - 2.2.2 Pause, Stop, Hide (A). Any auto-playing motion lasting >5s must offer pause/stop. Auto-carousels and marquees fail this regardless of the media query — give a control too.
Deliver & verify (standalone HTML)
Packaged helper (
scripts/):scripts/seek-shot.sh anim.html 0 1.5 3freezes the?t=Nharness and screenshots each moment;scripts/contact-sheet.sh sheet.png frame-*.pngtiles them for one-glance review. Seescripts/README.md.
For a self-contained demo the deliverable is one HTML file that opens directly in a browser — markup, CSS, and any JS (GSAP/matchMedia from CDN) inline, no build step. For this skill the verification is the point: you must screenshot both the normal and the reduced-motion path and confirm the tiering is correct.
Output contract:
- One
.htmlfile with the full motion AND its tiered reduced-motion overrides (CSS query +matchMedia/gsap.matchMedia()for JS-driven motion). - A seek harness to freeze a frame, plus a way to force the reduced-motion code path for screenshots.
Seek harness — freeze a frame, force the preference. ?t=N freezes the timeline; ?reduce=1 forces the reduced path even when the OS setting is off (CSS can't be toggled from JS, so query the same flag you gate JS on, and screenshot with the OS/browser preference emulated for the CSS layer):
<script>
const q = new URLSearchParams(location.search);
const reduce = q.get("reduce") === "1"
|| window.matchMedia("(prefers-reduced-motion: reduce)").matches;
// build motion conditionally on `reduce` (Tier-1 removed, Tier-2 softened, Tier-3 kept)
const t = q.get("t");
if (t !== null) { tl.pause(); tl.seek(parseFloat(t)); } // GSAP; CSS: el.style.animationDelay=(-t)+"s"; playState="paused"
window.__ready = true;
</script>
Verify loop — screenshot BOTH states: capture the normal path AND the reduced path, mid-animation each, and confirm Tier-1 motion is gone, Tier-2 is a short fade, Tier-3 survives. Emulate the preference for the CSS layer (Playwright --reduced-motion=reduce; the agent's browser tool can emulate it too):
npx playwright screenshot --wait-for-timeout=500 "file://$PWD/demo.html?t=0.6" normal.png
npx playwright screenshot --reduced-motion=reduce --wait-for-timeout=500 "file://$PWD/demo.html?t=0.6&reduce=1" reduced.png
Before you finish:
- Opens standalone — no console errors, CDN (if any) loads.
- The freeze +
?reduce=1(and--reduced-motion=reduce) reliably exercises both code paths. - Screenshotted in BOTH states, mid-animation — normal looks intentional, reduced strips Tier-1/softens Tier-2.
prefers-reduced-motionhonored as tiering, not a kill switch — no teleporting, Tier-3 fades/focus rings/spinners kept; any >5s auto-motion still has a pause control (2.2.2).- Easing is intentional in both paths — no accidental
linear, durations sane (reduced fades ≤200ms,0.01msnot0s).
Quick reference
| Motion type | Tier | Reduced behavior |
|---|---|---|
| Parallax / depth | 1 | Remove (transform: none) |
| Large slide / translate | 1 | Remove or replace with fade |
| Scale / zoom (large) | 1 | Remove |
| Spin / 3D rotate | 1 | Remove (animation: none) |
| Auto carousel / marquee | 1 | Stop + provide pause control (2.2.2) |
| Smooth-scroll (Lenis) | 1 | Don't instantiate |
| Small slide / pop-in | 2 | Cross-fade ≤200ms |
| Opacity fade | 3 | Keep (shorten if long) |
| Color / focus-ring transition | 3 | Keep |
| Loading spinner | 3 | Keep (essential feedback) |
Gotchas
animation-duration: 0scan break code waiting onanimationend/transitionend; use0.01msso the event still fires.- The global
*reset alone over-removes Tier 3 motion; always layer intentional overrides. - Forgetting
animation-iteration-count: 1leaves infinite spins running at near-zero duration (CPU churn, still animating). - No media query covers JS/canvas/WebGL — gate those with
matchMediaor the loop never stops. - Toggling the OS setting fires no page reload; without a
changelistener the page keeps its stale state. - SSR: reading
matchMediaduring render throws or mismatches; default to motion and sync in an effect. - Auto-playing motion needs a visible pause control even when reduced-motion is off (2.2.2 is Level A).
Reference files
references/patterns.md— Full GSAPmatchMediateardown, Framer MotionMotionConfig, Lenis start/stop on live toggle, a reusableanimateWithMotionPreferencewrapper, marquee with pause control, and a tier-classification audit checklist.
Related skills
More from iart-ai/web-animation-skills and the wider catalog.

gsap-web
Code-driven web animations: scroll storytelling, timelines, text reveals, and layout transitions with GSAP.

micro-interaction
Add responsive UI motion: hover effects, toggles, toasts, drawers, and layout transitions with Framer Motion or CSS.

page-transition-animation
Animate page transitions in Next.js App Router with Framer Motion or View Transitions API.

svg-animation
Animate SVGs with draw-on strokes, morphing paths, motion-along-path, and gradient effects.

baseline-ui
Enforce UI baseline constraints to prevent AI-generated interface slop.

create-design-md
Extract and document design systems from repositories or live websites into persistent DESIGN.md files.