Guide · Build

Accessible scroll animation with prefers-reduced-motion

By Md Mahafuj Alam · Updated

prefers-reduced-motion tells you a visitor has asked their operating system for less movement, often because motion makes them dizzy or sick. A good scroll story reads that setting in CSS and JavaScript, switches off smooth scrolling and scrubbed frame playback, and shows the same story as still key frames with all the copy intact. This guide shows the detection code, the GSAP and Lenis switch, and the WCAG 2.2 criteria that apply.

What prefers-reduced-motion is and who turns it on

prefers-reduced-motion is a CSS media feature. It reports a setting the visitor chose in their operating system: Reduce motion on macOS and iOS, Remove animations on Android, and turning off Animation effects on Windows. The browser exposes it as one of two values, no-preference or reduce.

The people who switch it on are often living with vestibular disorders, which affect the inner ear and the sense of balance. For them, large movement on screen can cause dizziness, nausea or headaches. Parallax is a known trigger because foreground and background move at different speeds. A cinematic scroll story is parallax at full strength: a camera flying through a scene, layers drifting, text sliding in. That is exactly the kind of page this setting exists for.

Others use it to reduce distraction, to save battery, or simply because they dislike motion. You do not need to know why. Treat reduce as a clear instruction: remove the movement that is decoration and keep everything that carries meaning.

The web.dev article prefers-reduced-motion: Sometimes less movement is more is the clearest primary reference for the feature and how browsers map it to system settings.

Detecting the setting in CSS and JavaScript

CSS handles the easy part. Any keyframe animation or transition you write can be wrapped so it only runs for visitors with no preference, or neutralised for those who asked for less. A blanket rule is a useful safety net for third-party components you do not control.

globals.csscss
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

A scroll story is mostly JavaScript, and JavaScript does not react to media queries on its own. You read the query with window.matchMedia, then listen for the change event so the page responds if the visitor flips the setting while the tab is open. The parentheses around the query are required; matchMedia('prefers-reduced-motion: reduce') without them never matches.

hooks/useReducedMotion.tsts
'use client';
import { useEffect, useState } from 'react';

const QUERY = '(prefers-reduced-motion: reduce)';

export function useReducedMotion(): boolean {
  const [reduced, setReduced] = useState(false);

  useEffect(() => {
    const mq = window.matchMedia(QUERY);
    setReduced(mq.matches);
    const onChange = (e: MediaQueryListEvent) => setReduced(e.matches);
    mq.addEventListener('change', onChange);
    return () => mq.removeEventListener('change', onChange);
  }, []);

  return reduced;
}

On a static export the first paint comes from prerendered HTML, before this hook runs. Make that HTML the calm version: a poster image and the full copy. The motion version then layers on top once JavaScript confirms the visitor has no preference. Visitors who asked for less never see a flash of animation.

What a good reduced version of a scroll story looks like

Reduced motion does not mean a blank page or a broken one. The story, the copy and the calls to action must all survive. What changes is how the visitor moves through it.

  • Static key frames. Pick one frame per chapter from your image sequence, the frame that best tells that beat, and show it as a normal image beside or behind the chapter text. A 600-frame story might become six stills.
  • Native scrolling. No smooth-scroll library, no scroll hijacking, no snapping. The page scrolls at the speed and distance the visitor's own device gives them.
  • No pinning. Pinned sections exist to hold the frame still while scroll drives playback. Without playback, a pin only traps the visitor in place. Let sections flow as ordinary blocks.
  • Fades instead of travel. Opacity changes that do not alter an element's size, shape or position are not motion animation in WCAG's terms. A short cross-fade between stills is acceptable; a camera move is not.
  • Complete content. Any text that only appeared mid-scrub must still be in the reduced layout. Audit by reading the page top to bottom with the setting on.

The bonus is speed. Six stills weigh a fraction of a few hundred frames, so the reduced path also suits slow connections. You can reuse the same logic in your mobile performance plan.

Turning off Lenis and scrubbed timelines

GSAP has a built-in tool for this: gsap.matchMedia(). You register a handler per media query. GSAP runs the handler when the query matches and reverts every tween and ScrollTrigger created inside it when the query stops matching. That revert includes pins, so the page returns to normal flow without manual cleanup.

Lenis is not a GSAP object, so you destroy it yourself in the cleanup function the handler returns. The pattern below creates Lenis and the scrubbed frame timeline only for visitors with no preference, and sets a data attribute for the reduced layout otherwise.

lib/initScrollStory.tsts
import gsap from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';
import Lenis from 'lenis';

gsap.registerPlugin(ScrollTrigger);

export function initScrollStory(drawFrame: (index: number) => void, frameCount: number) {
  const mm = gsap.matchMedia();

  mm.add('(prefers-reduced-motion: no-preference)', () => {
    const lenis = new Lenis();
    lenis.on('scroll', ScrollTrigger.update);
    const tick = (time: number) => lenis.raf(time * 1000);
    gsap.ticker.add(tick);
    gsap.ticker.lagSmoothing(0);

    const state = { frame: 0 };
    gsap.to(state, {
      frame: frameCount - 1,
      ease: 'none',
      snap: 'frame',
      onUpdate: () => drawFrame(state.frame),
      scrollTrigger: {
        trigger: '#story',
        start: 'top top',
        end: 'bottom bottom',
        scrub: true,
      },
    });

    return () => {
      gsap.ticker.remove(tick);
      gsap.ticker.lagSmoothing(500, 33);
      lenis.destroy();
    };
  });

  mm.add('(prefers-reduced-motion: reduce)', () => {
    document.documentElement.dataset.motion = 'reduced';
    return () => {
      delete document.documentElement.dataset.motion;
    };
  });

  return () => mm.revert();
}

Your CSS then shows the key-frame stills under [data-motion='reduced'] and hides the canvas. Because GSAP reruns the handlers when the setting changes, a visitor who turns on Reduce motion mid-visit gets the calm layout without a reload. The GSAP, ScrollTrigger and Lenis setup guide covers the full wiring in Next.js.

Keyboard navigation and focus in pinned sections

Pinned sections break keyboard use in two common ways, and both affect every visitor, not only those with reduced motion.

Focus hidden behind a pin

When a pinned panel sits fixed over the page, a link or button further down can receive focus while the panel still covers it. WCAG 2.2 added success criterion 2.4.11 Focus Not Obscured (Minimum), Level AA, for this case: a focused component must not be entirely hidden by author-created content. Tab through the whole page with the motion version on. If the focus ring ever disappears under the canvas or a sticky header, add scroll-margin-top to focusable elements or restructure the pin so its content is the focusable content.

Tab order that fights the scroll

Chapter text that fades in at a scroll position is still in the DOM, so keyboard focus can jump to it early and the browser scrolls to it. Keep the DOM order identical to the visual story order. Do not hide upcoming chapters with visibility: hidden or display: none if they contain links, because that removes them from the tab sequence until the scrub reaches them.

Also test the keyboard scroll keys: Space, Page Down, the arrow keys and Home and End. Smooth-scroll libraries intercept wheel and touch input; check that keyboard scrolling still moves the story forward and that End reaches the footer.

Readable text over video and image frames

Scroll stories place headings over moving footage. Each frame has a different background, so text that is legible on frame 40 can vanish on frame 300 when a bright sky passes behind it. WCAG 1.4.3 Contrast (Minimum), Level AA, asks for at least 4.5:1 for normal text and 3:1 for large text (18 point, or 14 point bold). W3C lists background images without enough contrast as a known failure.

  • Put a scrim behind copy: a gradient from transparent to a dark tone under the text block, drawn in CSS so it does not move.
  • Check contrast against the lightest frame under each text block, not the average. Export that frame and test it.
  • Avoid placing text where the footage changes most, such as a light source sweeping across.
  • In the reduced version, put text beside the still rather than over it where you can.

The WCAG 2.2 criteria that apply

Several WCAG 2.2 success criteria bear on scroll animation. The table lists the ones this guide relies on, with their level as published by W3C.

CriterionLevelWhat it asks of a scroll story
2.3.3 Animation from InteractionsAAAMotion animation triggered by interaction can be disabled, unless it is essential. Scrolling itself is essential; decorative effects added to scrolling, such as parallax, are not.
2.2.2 Pause, Stop, HideAMoving content that starts automatically, lasts more than five seconds and sits alongside other content needs a way to pause, stop or hide it. Applies to autoplaying background video and looping hero clips.
2.4.11 Focus Not Obscured (Minimum)AAA focused component must not be entirely hidden by author content such as a pinned panel.
1.4.3 Contrast (Minimum)AA4.5:1 for normal text, 3:1 for large text, including text over frames.

2.3.3 is Level AAA, so most legal and procurement targets, which stop at AA, do not strictly require it. Honouring prefers-reduced-motion is still the standard way to meet it, and it costs little once the code above is in place. 2.2.2 is Level A, the baseline: a looping hero video with no pause control fails it. Scrub-driven frames do not start automatically, but any autoplay loop does.

Read the W3C Understanding documents for 2.3.3 Animation from Interactions and 2.2.2 Pause, Stop, Hide before you sign off a build.

A test checklist before launch

  1. Turn on Reduce motion in the operating system and reload. No smooth scroll, no pins, no scrub, stills in place.
  2. Toggle the setting with the page open. The layout switches without a reload.
  3. Read every chapter with the setting on. No copy or button is missing.
  4. Check the network panel in the reduced path. The full frame sequence is not requested.
  5. Tab through the motion version. The focus ring is always visible.
  6. Scroll with Space, Page Down and End. The story advances and the footer is reachable.
  7. Any autoplaying video longer than five seconds has a visible pause control.
  8. Text contrast passes against the lightest frame behind it.

The Orbitly template respects reduced motion out of the box, so you can compare your build against a working reference. Browse the rest in the template catalogue, or start from the complete guide to building a 3D website with Claude if you are planning a story from scratch.

FAQ

Questions, answered.

The questions people ask most about this topic.

01Does prefers-reduced-motion mean I must remove all animation?

No. Remove motion that is decoration: parallax, camera moves, scroll-scrubbed playback and smooth scrolling. Keep motion that is essential to understanding, and keep simple opacity fades, which WCAG does not treat as motion animation.

02Is honouring reduced motion a legal requirement?

The WCAG criterion that covers it, 2.3.3 Animation from Interactions, is Level AAA. Most regulations reference Level AA, so it is rarely mandated. It is still expected good practice, and related criteria such as 2.2.2 Pause, Stop, Hide are Level A.

03Should I turn off Lenis for reduced-motion visitors?

Yes. Smooth scrolling changes the distance and speed of every scroll gesture, which is the kind of movement these visitors asked to avoid. Create Lenis only inside the no-preference branch and destroy it when the setting changes.

04Can I offer my own motion toggle as well?

Yes, and it helps visitors who have not found the system setting. Store the choice and let it override the media query. The system setting should still be the default.

05How do I test reduced motion without changing my system settings?

Chrome DevTools can emulate the media feature from the Rendering panel, under Emulate CSS media feature prefers-reduced-motion. Test on a real device with the system setting too, because that is what visitors use.