Content
Scroll effects
Parts that rise into view, layers with depth, lines that draw themselves, and scenes that tell a story as people scroll. With no script, and still for anyone who asks for less motion.
When to use
- On a homepage, a campaign or an information page, to make the page feel alive and to show how things fit together, as the GGDS homepage does.
When not to use
- Inside a service's steps: questions, check your answers, errors, payment and confirmation. People finishing a task need a still page. A GGDS test checks that no form component or pattern uses these classes.
- To hide content until people scroll to it, or to make them wait. The words must be there and readable without the movement.
- On text people read for long. Move pictures, cards and headings, not paragraphs.
How to use
- Add a class to the part that should move:
ggds-revealon a heading or card,ggds-staggeron a list or grid,ggds-parallaxon a picture behind the text,ggds-drawon an SVG drawing (give each pathpathLength="1"). - To tell a story, use a scene: a
<section class="ggds-scene ggds-scene--pinned">holding oneggds-scene__stagewith the words and a picture. Give each part of the pictureggds-scene__partand its turn,--2to--6. The scene stays on screen while people scroll, and its parts arrive in order. Put the words first and the picture after them, as the stage's two children. - Choose how a part arrives: it rises by default, or
--fade,--grow,--from-start,--from-endor--draw. - Keep it small: a few things moving at once, never the whole page.
Accessibility
What GGDS does
- Nothing moves for people who have asked their device for less motion: they see the finished page (WCAG 2.3.3).
- Browsers without scroll-driven animations show the same still, finished page. Nothing is ever hidden waiting for an animation.
- Movement follows the person's own scrolling: nothing plays by itself, and the scroll is never slowed or taken over.
- Only position, transparency and SVG lines move, so the page never jumps.
- Cards and list items rise without fading, so their words are at full contrast even when they are only half way on screen. Only pictures and headings fade.
- A pinned scene stays pinned only on a screen wide and tall enough to hold its words beside its picture. On a phone, at high zoom or on a short screen it is an ordinary section, so nothing is cut off (WCAG 1.4.10). On a phone the picture still builds itself as it rises up the screen, and drifts a little slower than the words, so people never scroll past words that do not move.
What you need to do
- Write the words so they make sense without the pictures: a scene's heading and text carry its meaning.
- Give a drawing a text alternative, or hide it from screen readers (
aria-hidden="true") when the text already says it all.
Example: Cards that arrive one after another
<h2 class="ggds-reveal">What you can do</h2>
<p>Scroll down: the cards arrive in turn. With less motion turned on, they are simply there.</p>
<p>Government websites built with GGDS look and work the same way, so people who have used one can use them all. Each institution keeps its own colour, and every part is tested with a keyboard, a screen reader and on a small phone before it is published.</p>
<p>The effects follow your own scrolling. Nothing plays by itself, and the page never jumps.</p>
<ul class="ggds-card-grid ggds-stagger">
<li class="ggds-card"><h3 class="ggds-card__title"><a class="ggds-card__link" href="#apply">Apply for a licence</a></h3><p class="ggds-card__body">Online, in about 10 minutes.</p></li>
<li class="ggds-card"><h3 class="ggds-card__title"><a class="ggds-card__link" href="#pay">Pay a fee</a></h3><p class="ggds-card__body">By mobile money or card.</p></li>
<li class="ggds-card"><h3 class="ggds-card__title"><a class="ggds-card__link" href="#track">Track your application</a></h3><p class="ggds-card__body">With your reference number.</p></li>
</ul><>
<h2 className="ggds-reveal">What you can do</h2>
<p>Scroll down: the cards arrive in turn. With less motion turned on, they are simply there.</p>
<p>Government websites built with GGDS look and work the same way, so people who have used one can use them all. Each institution keeps its own colour, and every part is tested with a keyboard, a screen reader and on a small phone before it is published.</p>
<p>The effects follow your own scrolling. Nothing plays by itself, and the page never jumps.</p>
<ul className="ggds-card-grid ggds-stagger">
<li className="ggds-card"><h3 className="ggds-card__title"><a className="ggds-card__link" href="#apply">Apply for a licence</a></h3><p className="ggds-card__body">Online, in about 10 minutes.</p></li>
<li className="ggds-card"><h3 className="ggds-card__title"><a className="ggds-card__link" href="#pay">Pay a fee</a></h3><p className="ggds-card__body">By mobile money or card.</p></li>
<li className="ggds-card"><h3 className="ggds-card__title"><a className="ggds-card__link" href="#track">Track your application</a></h3><p className="ggds-card__body">With your reference number.</p></li>
</ul>
</>Example: A scene that stays while its story plays
<section class="ggds-scene ggds-scene--pinned" aria-labelledby="scene-title">
<div class="ggds-scene__stage">
<h2 id="scene-title">From thread to cloth</h2>
<p>Scroll: the threads draw themselves, the strips arrive, and the cloth comes together. On a short screen, at high zoom or with less motion, you see the finished cloth.</p>
<svg viewBox="0 0 320 200" width="320" height="200" aria-hidden="true" focusable="false">
<path class="ggds-scene__part ggds-scene__part--draw" d="M10 30H310" pathLength="1" fill="none" stroke="#fcd116" stroke-width="6"/>
<path class="ggds-scene__part ggds-scene__part--draw ggds-scene__part--2" d="M10 50H310" pathLength="1" fill="none" stroke="#ce1126" stroke-width="6"/>
<rect class="ggds-scene__part ggds-scene__part--from-start ggds-scene__part--3" x="60" y="80" width="60" height="110" fill="#006b3f"/>
<rect class="ggds-scene__part ggds-scene__part--4" x="130" y="80" width="60" height="110" fill="#fcd116"/>
<rect class="ggds-scene__part ggds-scene__part--from-end ggds-scene__part--5" x="200" y="80" width="60" height="110" fill="#ce1126"/>
</svg>
</div>
</section><section className="ggds-scene ggds-scene--pinned" aria-labelledby="scene-title">
<div className="ggds-scene__stage">
<h2 id="scene-title">From thread to cloth</h2>
<p>Scroll: the threads draw themselves, the strips arrive, and the cloth comes together. On a short screen, at high zoom or with less motion, you see the finished cloth.</p>
<svg viewBox="0 0 320 200" width="320" height="200" aria-hidden="true" focusable="false">
<path className="ggds-scene__part ggds-scene__part--draw" d="M10 30H310" pathLength="1" fill="none" stroke="#fcd116" strokeWidth="6" />
<path className="ggds-scene__part ggds-scene__part--draw ggds-scene__part--2" d="M10 50H310" pathLength="1" fill="none" stroke="#ce1126" strokeWidth="6" />
<rect className="ggds-scene__part ggds-scene__part--from-start ggds-scene__part--3" x="60" y="80" width="60" height="110" fill="#006b3f" />
<rect className="ggds-scene__part ggds-scene__part--4" x="130" y="80" width="60" height="110" fill="#fcd116" />
<rect className="ggds-scene__part ggds-scene__part--from-end ggds-scene__part--5" x="200" y="80" width="60" height="110" fill="#ce1126" />
</svg>
</div>
</section>Use it
- Stylesheet
ggds.cssincludes it. To load only the parts you use:core.css, thencomponents/motion.css(0.9 KB with gzip, minified).- JavaScript
- None needed.
HTML
Copy the HTML under each example above. It works in any website.
Astro
No Astro component: copy the HTML.
React and Next.js
No React component: switch the HTML under an example to JSX (React) and copy it.
Django
No template tag: copy the HTML into your template.
Classes and states
| Class | What it does |
|---|---|
.ggds-reveal | Rises into place as it comes into view. |
.ggds-reveal--fade | Fades in instead of rising. |
.ggds-reveal--scale | Grows into place instead of rising. |
.ggds-stagger | On a list or grid: each child arrives a little after the one before it. It rises without fading, so its words are always at full contrast. |
.ggds-parallax | A layer that moves a little against the scroll, for depth. |
.ggds-parallax--near | Moves more: a layer that seems closer. |
.ggds-parallax--far | Moves less: a layer that seems further away. |
.ggds-draw | On an SVG: its lines draw themselves as it comes into view. Give each path pathLength="1". |
.ggds-scene | A part of the page that tells a story as people scroll. Its parts use its own timeline. |
.ggds-scene--pinned | The scene stays on screen while people scroll through it, and its parts play in order. Only on screens wide and tall enough to hold its words beside its picture; on a phone the picture builds itself as it rises up the screen. |
.ggds-scene__stage | What stays on screen in a pinned scene: the words and the picture. |
.ggds-scene__part | One part of the picture, which arrives in its turn: first by default, or --2 to --6 for later turns. |
.ggds-scene__part--* | How and when it arrives: --fade, --grow, --from-start, --from-end, --draw (an SVG line drawing itself), and its turn, --2 to --6. |
| State | What it does |
|---|---|
prefers-reduced-motion: reduce | Nothing moves: the page is still and finished. |
no scroll-driven animations | A browser without them shows the still, finished page. |
Accessibility tests
Automated, on every change
These run each time GGDS changes. A change that fails one is not accepted.
- WCAG 2.2 A and AA rules (axe), at desktop and phone widths, on every example
- No sideways scrolling on a 320px screen, also with a wide font, on every example
- Every approved colour pair meets its contrast minimum, for every institution theme
- No inline scripts or styles, so it runs under a strict Content Security Policy
- Behaviour test: “scroll effects: still and fully visible for people who ask for less motion, and play as people scroll otherwise”
By people, with assistive technology
Automated tests find only some of the barriers people meet. These checks are still to be done.
| Check | Result | Notes |
|---|---|---|
| Keyboard only | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| NVDA screen reader with Firefox or Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| JAWS screen reader with Chrome (Windows) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| VoiceOver screen reader with Safari (iPhone) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| TalkBack screen reader with Chrome (Android) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Zoom to 400%, and increased text spacing | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Windows contrast themes (forced colours) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
| Voice control (Voice Access or Dragon) | Not tested yet | Waiting for the external audit with disabled people (decision D-09). |
Changes
| Version | Change |
|---|---|
| 0.5.0 | New: scroll effects, played by the browser from the scroll position, with no script: ggds-reveal (rise, fade or grow into view), ggds-stagger (a list's items in turn), ggds-parallax (layers with depth), ggds-draw (SVG lines that draw themselves) and ggds-scene (a story that plays as people scroll, pinned on screen with its parts arriving in order). Still and finished for anyone who asks for less motion and in browsers without scroll-driven animations; a pinned scene is an ordinary section on a short screen or at high zoom, so nothing is cut off. Only position, transparency and SVG lines move, so the page never jumps. Under 2 KB with compression. |
| 0.1.0 | Added. |
Related components
Something wrong, unclear or missing? or suggest a change to it on GitHub. You need a GitHub account.