Accessible motion: a checklist for animated React components
Animation should never be the only way to see, reach or understand something. Honour reduced motion and transparency, show a focus ring, support the keyboard, announce status changes, use 44 px touch targets and let people pause loops. Each section shows the code Framekit uses.
Updated · 4 min read
Reduced motion
When prefers-reduced-motion: reduce matches, keep final states, swap movement for a short fade and stop loops, parallax and particles. Large motion can make people with vestibular disorders feel sick (WCAG 2.3.3).
Every animated Framekit component ships this hook as lib/use-reduced-motion.ts:
lib/use-reduced-motion.ts
import { useEffect, useState } from 'react'
export function usePrefersReducedMotion() {
const [reduced, setReduced] = useState(false)
useEffect(() => {
const mq = window.matchMedia('(prefers-reduced-motion: reduce)')
const update = () => setReduced(mq.matches)
update()
mq.addEventListener('change', update)
return () => mq.removeEventListener('change', update)
}, [])
return reduced
}Branch on it inside the component so copied files keep the behaviour. With it on, Perspective Tunnel Carousel becomes a static scroll-snap row and Infinite Marquee wraps into a still grid. Chrome DevTools can emulate the setting from its Rendering panel.
Reduced transparency
Glass lowers text contrast over busy backgrounds. When prefers-reduced-transparency: reduce matches, swap the translucent surface for an opaque one (WCAG 1.4.3 and 1.4.11).
From Glass App Dock, using Tailwind v4’s arbitrary media variant:
Opaque fallback for glass
<div className="bg-white/60 backdrop-blur-2xl dark:bg-zinc-900/60
[@media(prefers-reduced-transparency:reduce)]:bg-white
[@media(prefers-reduced-transparency:reduce)]:dark:bg-zinc-900" />Heads-up: Only Chromium browsers honour this query so far. Make the glass pass contrast on its own and treat the fallback as a bonus.
Focus
Every control needs a visible ring on keyboard focus that sticky headers and animated layers can’t cover. Use :focus-visible with a 2 px ring at 3:1 contrast or better (WCAG 2.4.7 and 2.4.11).
Framekit’s focus ring
<button className="rounded-full outline-none
focus-visible:ring-2 focus-visible:ring-signal-600 focus-visible:ring-offset-2
ring-offset-white dark:ring-signal-300 dark:ring-offset-zinc-950">
Save
</button>Keep the ring out of overflow: hidden parents, which clip it, and give anchors under a sticky header a scroll-margin-top.
Keyboard
Anything a pointer can do must work from the keyboard, focus must never get stuck, and every drag needs a click or key alternative (WCAG 2.1.1, 2.1.2, 2.5.7). Start from native elements.
| Pattern | Keys | Example |
|---|---|---|
| Button, toggle | Enter or Space | Magnetic Button |
| Tabs, segmented control | Arrows, Home, End; one Tab stop | Glass Segmented Control |
| Menu, command palette | Up, Down, Enter; Esc closes and returns focus | Spotlight Command Palette |
| Modal dialog | Focus stays inside; Esc returns it to the trigger | Morph Button Modal |
| Swipe or drag | Buttons or arrow keys do the same thing | Swipe Cards |
Framekit’s tablists share one roving-focus handler. Simplified from lib/roving.ts:
lib/roving.ts (simplified)
export function handleTablistKeys(e: React.KeyboardEvent<HTMLElement>) {
const items = Array.from(e.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]:not([disabled])'))
const i = items.indexOf(document.activeElement as HTMLElement)
let n = -1
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') n = (i + 1) % items.length
else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') n = (i - 1 + items.length) % items.length
else if (e.key === 'Home') n = 0
else if (e.key === 'End') n = items.length - 1
if (n < 0) return
e.preventDefault()
items[n].focus()
items[n].click()
}Status announcements
Put status text in a role="status" region that is already in the DOM, then change its text. Use role="alert" only for errors. Screen readers hear the change without focus moving (WCAG 4.1.3).
Announce what the animation shows
<span role="status" aria-live="polite" aria-atomic="true" className="sr-only">
{state === 'done' ? 'Ready' : state === 'error' ? 'Something went wrong' : 'Loading'}
</span>
{error && <p role="alert">{error}</p>}Announce the meaning (“Saved”), not the motion. Decorative layers get aria-hidden; animated text like scrambles keeps an sr-only copy.
Target size
WCAG 2.2 asks for targets of at least 24 × 24 px (2.5.8). Framekit goes to 44 × 44 on touch screens, the size Apple recommends, with pointer-coarse:min-h-11, and stays compact with a mouse.
Compact on desktop, 44 px on touch
<button className="h-8 px-3 text-xs pointer-coarse:min-h-11">Filter</button>Grow small icons with padding, not invisible overlays, and don’t shrink a target mid-animation.
Pause controls
Anything that starts on its own and runs for more than five seconds next to other content needs a pause control (WCAG 2.2.2). Marquees, carousels and ambient backgrounds all count. Pause them off-screen too.
A real toggle, plus automatic pausing
const [paused, setPaused] = React.useState(false)
<button type="button" aria-pressed={paused} onClick={() => setPaused((p) => !p)}>
{paused ? 'Play' : 'Pause'}
</button>
// Stop work nobody can see
useEffect(() => {
const io = new IntersectionObserver(([e]) => setVisible(e.isIntersecting))
io.observe(ref.current!)
const onVis = () => setVisible(document.visibilityState === 'visible')
document.addEventListener('visibilitychange', onVis)
return () => { io.disconnect(); document.removeEventListener('visibilitychange', onVis) }
}, [])Also pause on hover and focus, never flash more than three times a second (2.3.1), and don’t autoplay with reduced motion on. Infinite Marquee does all three.
The checklist
Run these in both themes, at 390 px wide, with reduced motion on and off, using only a keyboard and then a screen reader.
| Check | WCAG 2.2 | Level |
|---|---|---|
| Reduced motion keeps final states, drops movement | 2.3.3 | AAA |
| Loops over 5 s can be paused, and pause off-screen | 2.2.2 | A |
| No more than 3 flashes a second | 2.3.1 | A |
| Glass has an opaque fallback; text passes 4.5:1 | 1.4.3 | AA |
| 3:1 focus ring, never hidden | 2.4.7, 2.4.11 | AA |
| Everything works from the keyboard, no traps | 2.1.1, 2.1.2 | A |
| Drags have a click or key alternative | 2.5.7 | AA |
| Status changes reach a live region | 4.1.3 | AA |
| Targets 24 px minimum, 44 px on touch | 2.5.8 | AA |
Named controls; decorative layers aria-hidden | 4.1.2 | A |
axe and Lighthouse catch only some of these, so do a keyboard pass and a VoiceOver or NVDA pass before you ship.
FAQ
Does WCAG require prefers-reduced-motion support?
Not at AA: 2.3.3 is AAA. But 2.2.2 (Level A) covers motion that plays on its own, and honouring the OS setting is the usual way to meet it.
Is MotionConfig reducedMotion="user" enough?
It’s a good start. It skips Motion’s transform and layout animations, but not loops, canvas or CSS animation.
What’s the minimum touch target size in WCAG 2.2?
24 × 24 CSS pixels (2.5.8, AA), except inline links and well-spaced targets. Aim for 44 × 44 on touch.
Components in this guide
- Infinite Marquee
Seamless looping strip with masked edge fades; pauses on hover, focus or with an optional pause button. Wraps statically under reduced motion.
- Glass Segmented Control
An iOS-style segmented control whose selected thumb is a lifted glass pill that springs between segments with a press squish — native radio semantics, arrow keys and an opaque reduced-transparency…
- Cook Loading
An illustrated chef stirs a sizzling wok while your app loads — eight original cooking poses, drifting steam, real progress and ready/error states in one self-contained component.
- Morph Button Modal
A pill button that physically becomes its dialog: the surface expands on a shared-layout spring, the label blurs into a form, and submit shrinks it back into a success pill. Focus trapped and…