How it works, sticky scenes
A how-it-works section where the picture stays put and changes as you read: photos drop in a pile, snap into a book, words type onto the page and the finished book drives off.
"use client";
import { useEffect, useRef, useState, type CSSProperties } from "react";
import "./how-it-works.css";
export type HowStep = { title: string; text: string };
const PHOTOS = [18, 200, 330, 40, 160, 280, 90, 230, 10];
/** The scene on the right. Each step rearranges the same pieces, so it morphs instead of cutting. */
function Scene({ step }: { step: number }) {
return (
<div className="gu-how__scene" data-step={step} aria-hidden="true">
<div className="gu-how__book">
<div className="gu-how__page gu-how__page--l">
<span className="gu-how__words">
<i style={{ "--w": "80%" } as CSSProperties} />
<i style={{ "--w": "62%" } as CSSProperties} />
<i style={{ "--w": "70%" } as CSSProperties} />
</span>
</div>
<div className="gu-how__page gu-how__page--r" />
<span className="gu-how__spine" />
</div>
{PHOTOS.map((h, i) => (
<span
key={i}
className="gu-how__photo"
style={
{
"--h": h,
"--i": i,
"--col": i % 3,
"--row": Math.floor(i / 3),
"--rot": `${((i * 37) % 24) - 12}deg`,
} as CSSProperties
}
>
<span />
</span>
))}
<span className="gu-how__caret" />
<div className="gu-how__truck">
<svg viewBox="0 0 64 32">
<path d="M2 6h34v18H2zM36 12h14l8 8v4H36z" />
<circle cx="14" cy="26" r="4" />
<circle cx="48" cy="26" r="4" />
</svg>
<span className="gu-how__road" />
</div>
<span className="gu-how__badge">On its way · arrives Thursday</span>
</div>
);
}
/**
* HowItWorks: a "how it works" section where the picture stays put and changes as you read.
* - Steps scroll by on the left; the scene on the right is sticky and morphs to match the step in view.
* - A progress rail fills as you go and the current step number rolls.
* - On phones the scene sits above the steps, smaller, and still follows along.
*/
export function HowItWorks({
title,
intro,
steps,
theme = "light",
}: {
title: string;
intro: string;
steps: HowStep[];
theme?: "light" | "dark";
}) {
const [active, setActive] = useState(0);
const items = useRef<(HTMLLIElement | null)[]>([]);
useEffect(() => {
const io = new IntersectionObserver(
(entries) => {
for (const e of entries)
if (e.isIntersecting)
setActive(Number((e.target as HTMLElement).dataset.i));
},
{ rootMargin: "-45% 0px -45% 0px" },
);
items.current.forEach((el) => el && io.observe(el));
return () => io.disconnect();
}, [steps.length]);
return (
<section
className="gu-how"
data-theme={theme}
aria-labelledby="gu-how-title"
>
<header className="gu-how__head">
<h2 id="gu-how-title">{title}</h2>
<p>{intro}</p>
</header>
<div className="gu-how__body">
<div className="gu-how__sticky">
<div className="gu-how__frame">
<Scene step={active} />
<div className="gu-how__count" aria-hidden="true">
<span className="gu-how__num" key={active}>
{String(active + 1).padStart(2, "0")}
</span>
<span>/ {String(steps.length).padStart(2, "0")}</span>
</div>
</div>
</div>
<ol
className="gu-how__steps"
style={{ "--p": (active + 1) / steps.length } as CSSProperties}
>
{steps.map((s, i) => (
<li
key={s.title}
ref={(el) => {
items.current[i] = el;
}}
data-i={i}
data-state={i < active ? "done" : i === active ? "now" : "next"}
aria-current={i === active ? "step" : undefined}
>
<span className="gu-how__dot" aria-hidden="true" />
<h3>{s.title}</h3>
<p>{s.text}</p>
</li>
))}
</ol>
</div>
</section>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: How it works, sticky scenes
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A "how it works" section for a photo book service. Steps scroll by on the left; on the right a sticky square scene drawn entirely in code morphs to match the step in view, reusing the same pieces so it never cuts: photos drop into a pile, snap into a book's layout grid, words type onto the left page, then the book closes (orange cover) and a small truck drives off with an "On its way" badge.
## Layout and look
- Light: cream #f3eee3 background, ink #0e0e10 text, card #fffdf8; dark: the reverse with card #1a1a1f. Accent #ff5a1f.
- Centred header: headline clamp(36px, 6vw, 68px) weight 900, letter-spacing −0.045em; 18px intro at 72% opacity, max 48ch.
- Body: two columns (1.05fr steps / 1fr scene), max 1120px. Scene: square, radius 32px, sticky at 12vh, soft orange glow top-right, big shadow. A rolling step counter "02 / 04" in the corner (orange 34px number).
- Steps: an ordered list with a 2px rail on the left that fills orange as you progress, a 16px dot per step (orange with a halo when reached, bigger when current). Each step 62vh tall so one is in focus at a time; step titles 24–34px weight 800, body 17px. Future steps at 35% opacity, past at 55%.
## Behavior and motion
1. An IntersectionObserver with rootMargin "-45% 0px -45% 0px" sets the active step (the one crossing the middle of the screen).
2. Photos (9 white-bordered prints with gradient "pictures") are positioned with CSS per step, all transitions 900ms spring cubic-bezier(0.34,1.56,0.64,1) with a 30ms stagger: step 1 a scattered rotated pile that drops in; step 2 small and straight in a 3 × 3 grid on the right page; step 3 two hide; step 4 all shrink away.
3. The book (two pages and a spine) fades and scales in from step 2. Step 3: three bars grow on the left page one after another (title bar orange) while a caret blinks and moves. Step 4: the left page turns away (rotateY 180°), the right page becomes an orange cover, the truck drives along a dashed road and the badge drops in after 1.2s.
4. The counter number rolls up on change; the current step title nudges in.
## Phones (under 760px)
One column: the scene sits on top (16:10, max 34vh), pinned with position: sticky while steps scroll under it; steps 46vh tall.
## Accessibility
- A real section with a labelled h2, an ordered list, aria-current="step" on the active step. The scene is aria-hidden; all meaning is in the text.
- prefers-reduced-motion: the scene changes instantly between arrangements.
## Props
title, intro, steps ({ title, text }[], built for four), theme.
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### HowItWorks.tsx
```tsx
"use client";
import { useEffect, useRef, useState, type CSSProperties } from "react";
import "./how-it-works.css";
export type HowStep = { title: string; text: string };
const PHOTOS = [18, 200, 330, 40, 160, 280, 90, 230, 10];
/** The scene on the right. Each step rearranges the same pieces, so it morphs instead of cutting. */
function Scene({ step }: { step: number }) {
return (
<div className="gu-how__scene" data-step={step} aria-hidden="true">
<div className="gu-how__book">
<div className="gu-how__page gu-how__page--l">
<span className="gu-how__words">
<i style={{ "--w": "80%" } as CSSProperties} />
<i style={{ "--w": "62%" } as CSSProperties} />
<i style={{ "--w": "70%" } as CSSProperties} />
</span>
</div>
<div className="gu-how__page gu-how__page--r" />
<span className="gu-how__spine" />
</div>
{PHOTOS.map((h, i) => (
<span
key={i}
className="gu-how__photo"
style={
{
"--h": h,
"--i": i,
"--col": i % 3,
"--row": Math.floor(i / 3),
"--rot": `${((i * 37) % 24) - 12}deg`,
} as CSSProperties
}
>
<span />
</span>
))}
<span className="gu-how__caret" />
<div className="gu-how__truck">
<svg viewBox="0 0 64 32">
<path d="M2 6h34v18H2zM36 12h14l8 8v4H36z" />
<circle cx="14" cy="26" r="4" />
<circle cx="48" cy="26" r="4" />
</svg>
<span className="gu-how__road" />
</div>
<span className="gu-how__badge">On its way · arrives Thursday</span>
</div>
);
}
/**
* HowItWorks: a "how it works" section where the picture stays put and changes as you read.
* - Steps scroll by on the left; the scene on the right is sticky and morphs to match the step in view.
* - A progress rail fills as you go and the current step number rolls.
* - On phones the scene sits above the steps, smaller, and still follows along.
*/
export function HowItWorks({
title,
intro,
steps,
theme = "light",
}: {
title: string;
intro: string;
steps: HowStep[];
theme?: "light" | "dark";
}) {
const [active, setActive] = useState(0);
const items = useRef<(HTMLLIElement | null)[]>([]);
useEffect(() => {
const io = new IntersectionObserver(
(entries) => {
for (const e of entries)
if (e.isIntersecting)
setActive(Number((e.target as HTMLElement).dataset.i));
},
{ rootMargin: "-45% 0px -45% 0px" },
);
items.current.forEach((el) => el && io.observe(el));
return () => io.disconnect();
}, [steps.length]);
return (
<section
className="gu-how"
data-theme={theme}
aria-labelledby="gu-how-title"
>
<header className="gu-how__head">
<h2 id="gu-how-title">{title}</h2>
<p>{intro}</p>
</header>
<div className="gu-how__body">
<div className="gu-how__sticky">
<div className="gu-how__frame">
<Scene step={active} />
<div className="gu-how__count" aria-hidden="true">
<span className="gu-how__num" key={active}>
{String(active + 1).padStart(2, "0")}
</span>
<span>/ {String(steps.length).padStart(2, "0")}</span>
</div>
</div>
</div>
<ol
className="gu-how__steps"
style={{ "--p": (active + 1) / steps.length } as CSSProperties}
>
{steps.map((s, i) => (
<li
key={s.title}
ref={(el) => {
items.current[i] = el;
}}
data-i={i}
data-state={i < active ? "done" : i === active ? "now" : "next"}
aria-current={i === active ? "step" : undefined}
>
<span className="gu-how__dot" aria-hidden="true" />
<h3>{s.title}</h3>
<p>{s.text}</p>
</li>
))}
</ol>
</div>
</section>
);
}
```
### how-it-works.css
```css
.gu-how {
--bg: #f3eee3;
--fg: #0e0e10;
--soft: rgb(14 14 16 / 0.12);
--card: #fffdf8;
--accent: #ff5a1f;
--ease: cubic-bezier(0.16, 1, 0.3, 1);
--spring: cubic-bezier(0.34, 1.56, 0.64, 1);
background: var(--bg);
color: var(--fg);
padding: clamp(56px, 9vw, 120px) clamp(20px, 5vw, 64px);
font-family: ui-sans-serif, system-ui, sans-serif;
}
.gu-how[data-theme="dark"] {
--bg: #0e0e10;
--fg: #f3eee3;
--soft: rgb(243 238 227 / 0.14);
--card: #1a1a1f;
}
.gu-how__head {
max-width: 640px;
margin: 0 auto clamp(40px, 6vw, 72px);
text-align: center;
}
.gu-how__head h2 {
margin: 0;
font-size: clamp(36px, 6vw, 68px);
font-weight: 900;
letter-spacing: -0.045em;
line-height: 0.98;
}
.gu-how__head p {
margin: 16px auto 0;
max-width: 48ch;
font-size: 18px;
line-height: 1.5;
opacity: 0.72;
}
.gu-how__body {
display: grid;
grid-template-columns: 1.05fr 1fr;
gap: clamp(32px, 6vw, 96px);
max-width: 1120px;
margin: 0 auto;
}
.gu-how__sticky {
order: 2;
}
.gu-how__frame {
position: sticky;
top: 12vh;
aspect-ratio: 1;
border-radius: 32px;
background:
radial-gradient(80% 60% at 70% 20%, rgb(255 90 31 / 0.16), transparent 70%),
var(--card);
box-shadow:
0 30px 60px -30px rgb(0 0 0 / 0.35),
inset 0 0 0 1px var(--soft);
overflow: hidden;
}
.gu-how__count {
position: absolute;
left: 22px;
bottom: 18px;
display: flex;
align-items: baseline;
gap: 6px;
font-weight: 800;
font-variant-numeric: tabular-nums;
overflow: hidden;
z-index: 5;
padding: 2px 10px;
border-radius: 12px;
background: color-mix(in oklab, var(--card), transparent 15%);
}
.gu-how__num {
display: inline-block;
font-size: 34px;
letter-spacing: -0.03em;
color: var(--accent);
animation: gu-how-roll 0.6s var(--spring);
}
@keyframes gu-how-roll {
from {
translate: 0 100%;
opacity: 0;
}
}
.gu-how__count > span:last-child {
font-size: 14px;
opacity: 0.5;
}
/* ---------- Steps ---------- */
.gu-how__steps {
--p: 0;
position: relative;
list-style: none;
margin: 0;
padding: 0 0 0 40px;
}
.gu-how__steps::before,
.gu-how__steps::after {
content: "";
position: absolute;
left: 11px;
top: 8px;
bottom: 30vh;
width: 2px;
border-radius: 2px;
background: var(--soft);
}
.gu-how__steps::after {
background: var(--accent);
transform-origin: top;
scale: 1 var(--p);
transition: scale 0.8s var(--ease);
}
.gu-how__steps li {
position: relative;
min-height: 62vh;
padding-top: 2px;
transition: opacity 0.5s var(--ease);
}
.gu-how__steps li:last-child {
min-height: 40vh;
}
.gu-how__steps li[data-state="next"] {
opacity: 0.35;
}
.gu-how__steps li[data-state="done"] {
opacity: 0.55;
}
.gu-how__dot {
position: absolute;
left: -36px;
top: 6px;
width: 16px;
height: 16px;
border-radius: 50%;
background: var(--bg);
box-shadow: inset 0 0 0 2px var(--soft);
transition:
background-color 0.4s,
box-shadow 0.4s,
scale 0.5s var(--spring);
z-index: 1;
}
.gu-how__steps li:not([data-state="next"]) .gu-how__dot {
background: var(--accent);
box-shadow: 0 0 0 5px rgb(255 90 31 / 0.2);
}
.gu-how__steps li[data-state="now"] .gu-how__dot {
scale: 1.25;
}
.gu-how__steps h3 {
margin: 0;
font-size: clamp(24px, 3vw, 34px);
font-weight: 800;
letter-spacing: -0.03em;
}
.gu-how__steps p {
margin: 10px 0 0;
max-width: 42ch;
font-size: 17px;
line-height: 1.55;
opacity: 0.8;
}
.gu-how__steps li[data-state="now"] h3 {
animation: gu-how-pop 0.6s var(--ease);
}
@keyframes gu-how-pop {
from {
translate: -10px 0;
}
}
/* ---------- Scene: photos, book, words, truck ---------- */
.gu-how__scene {
position: absolute;
inset: 0;
}
.gu-how__photo {
position: absolute;
width: 22%;
aspect-ratio: 4 / 5;
border-radius: 8px;
padding: 5px;
background: #fff;
box-shadow: 0 10px 20px -10px rgb(0 0 0 / 0.45);
/* Step 1: a loose, scattered pile. */
left: calc(14% + var(--col) * 25%);
top: calc(10% + var(--row) * 26%);
rotate: var(--rot);
transition:
left 0.9s calc(var(--i) * 30ms) var(--spring),
top 0.9s calc(var(--i) * 30ms) var(--spring),
width 0.9s calc(var(--i) * 30ms) var(--spring),
rotate 0.9s calc(var(--i) * 30ms) var(--spring),
opacity 0.5s,
scale 0.6s var(--spring);
}
.gu-how__photo > span {
display: block;
height: 100%;
border-radius: 4px;
background:
radial-gradient(
circle at 70% 25%,
hsl(calc(var(--h) + 40) 90% 75%),
transparent 45%
),
linear-gradient(
170deg,
hsl(var(--h) 70% 62%),
hsl(calc(var(--h) + 60) 55% 32%)
);
}
.gu-how__scene[data-step="0"] .gu-how__photo {
animation: gu-how-drop 0.8s calc(var(--i) * 60ms) var(--spring) backwards;
}
@keyframes gu-how-drop {
from {
translate: 0 -40px;
opacity: 0;
scale: 1.2;
}
}
/* Step 2: photos snap into the book's layout grid. */
.gu-how__scene[data-step="1"] .gu-how__photo,
.gu-how__scene[data-step="2"] .gu-how__photo {
width: 12%;
left: calc(54% + var(--col) * 13%);
top: calc(26% + var(--row) * 17%);
rotate: 0deg;
padding: 2px;
border-radius: 3px;
}
.gu-how__scene[data-step="2"] .gu-how__photo:nth-child(n + 8) {
opacity: 0;
scale: 0.6;
}
.gu-how__scene[data-step="3"] .gu-how__photo {
opacity: 0;
scale: 0.4;
left: 44%;
top: 40%;
}
.gu-how__book {
position: absolute;
left: 8%;
right: 8%;
top: 20%;
height: 56%;
display: flex;
perspective: 1200px;
opacity: 0;
scale: 0.9;
transition:
opacity 0.5s,
scale 0.8s var(--spring),
translate 0.9s var(--ease),
left 0.9s var(--ease),
right 0.9s var(--ease);
}
.gu-how__scene:not([data-step="0"]) .gu-how__book {
opacity: 1;
scale: 1;
}
.gu-how__page {
flex: 1;
background: #fffdf8;
box-shadow:
inset 0 0 0 1px rgb(0 0 0 / 0.06),
0 20px 40px -20px rgb(0 0 0 / 0.5);
transition: rotate 1s var(--ease);
}
.gu-how__page--l {
border-radius: 10px 2px 2px 10px;
transform-origin: right center;
padding: 14% 10%;
}
.gu-how__page--r {
border-radius: 2px 10px 10px 2px;
background: linear-gradient(90deg, #ece6da, #fffdf8 12%);
}
.gu-how__spine {
position: absolute;
left: 50%;
top: 0;
bottom: 0;
width: 2px;
background: rgb(0 0 0 / 0.15);
}
/* Step 3: words type onto the left page. */
.gu-how__words {
display: grid;
gap: 10px;
}
.gu-how__words i {
display: block;
height: 10px;
width: 0;
border-radius: 5px;
background: #0e0e10;
opacity: 0.8;
transition: width 0.7s var(--ease);
}
.gu-how__words i:first-child {
height: 18px;
background: var(--accent);
opacity: 1;
}
.gu-how__scene[data-step="2"] .gu-how__words i,
.gu-how__scene[data-step="3"] .gu-how__words i {
width: var(--w);
}
.gu-how__scene[data-step="2"] .gu-how__words i:nth-child(2) {
transition-delay: 0.35s;
}
.gu-how__scene[data-step="2"] .gu-how__words i:nth-child(3) {
transition-delay: 0.7s;
}
.gu-how__caret {
position: absolute;
left: 12%;
top: 31%;
width: 2px;
height: 22px;
background: var(--accent);
opacity: 0;
}
.gu-how__scene[data-step="2"] .gu-how__caret {
opacity: 1;
animation:
gu-how-caret 1.05s 3 steps(1) forwards,
gu-how-type 1.05s var(--ease) forwards;
}
@keyframes gu-how-caret {
50% {
opacity: 0;
}
}
@keyframes gu-how-type {
to {
left: 36%;
top: 43%;
}
}
/* Step 4: the book closes and drives off. */
.gu-how__scene[data-step="3"] .gu-how__book {
left: 30%;
right: 30%;
translate: 0 -12%;
}
.gu-how__scene[data-step="3"] .gu-how__page--l {
rotate: y 180deg;
opacity: 0;
}
.gu-how__scene[data-step="3"] .gu-how__page--r {
border-radius: 4px 12px 12px 4px;
background: linear-gradient(150deg, #ff5a1f, #c2410c);
}
.gu-how__scene[data-step="3"] .gu-how__spine {
left: 0;
width: 8px;
background: #8a2c08;
}
.gu-how__truck {
position: absolute;
left: 0;
right: 0;
bottom: 22%;
height: 40px;
opacity: 0;
transition: opacity 0.4s;
}
.gu-how__truck svg {
position: absolute;
left: -20%;
bottom: 6px;
width: 64px;
fill: var(--fg);
stroke: var(--card);
stroke-width: 1.5;
}
.gu-how__road {
position: absolute;
left: 10%;
right: 10%;
bottom: 0;
height: 2px;
background: repeating-linear-gradient(
90deg,
var(--soft) 0 14px,
transparent 14px 24px
);
}
.gu-how__scene[data-step="3"] .gu-how__truck {
opacity: 1;
}
.gu-how__scene[data-step="3"] .gu-how__truck svg {
animation: gu-how-drive 1.6s 0.3s var(--ease) forwards;
}
@keyframes gu-how-drive {
to {
left: 64%;
}
}
.gu-how__badge {
position: absolute;
right: 18px;
top: 18px;
padding: 8px 14px;
border-radius: 999px;
background: var(--fg);
color: var(--bg);
font-size: 13px;
font-weight: 700;
opacity: 0;
translate: 0 -10px;
transition:
opacity 0.4s,
translate 0.5s var(--spring);
}
.gu-how__scene[data-step="3"] .gu-how__badge {
opacity: 1;
translate: 0 0;
transition-delay: 1.2s;
}
@media (max-width: 760px) {
.gu-how__body {
grid-template-columns: 1fr;
gap: 24px;
}
.gu-how__sticky {
order: 0;
position: sticky;
top: 0;
z-index: 2;
padding: 8px 0;
background: var(--bg);
}
.gu-how__frame {
position: relative;
top: 0;
aspect-ratio: 16 / 10;
max-height: 34vh;
margin: 0 auto;
}
.gu-how__steps li {
min-height: 46vh;
}
}
@media (prefers-reduced-motion: reduce) {
.gu-how *,
.gu-how *::before,
.gu-how *::after {
animation-duration: 0.01ms !important;
animation-delay: 0ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
transition-delay: 0ms !important;
}
}
```
You might also want
Next piece: Integrations orbitChangelog timeline
Templates, intermediate
Scroll-drawn timeline
Templates, intermediate
Bento features grid
Templates, intermediate