Skip to content
motionprompts motionprompts

Anchored Card Step Scroll

GSAP animation component · Published 2026-11-21 · by vanguardia.dev

Open live demo ↗ Raw prompt (.md)

What it does

Scroll-pinned how-it-works section: a sticky stage holds a vertical step index with a filling progress line, a headline and paragraph that cross-fade with a ±25px vertical shift tied to scroll, and an anchored phone card whose stacked UI layers swap with each step. One scrubbed timeline drives texts and layers; the index converts scroll progress into the active step.

How it's built

Categoryscroll
Techgsap
GSAP pluginsScrollTrigger
Complexitysection
Performance costlight
Mobile-safeyes

sticky pinned steps cross-fade scrub phone-mockup progress-line scrolltrigger

Rebuild it with AI

To reproduce this animation in your own project, copy the prompt below into Claude Code, Cursor or any AI coding agent. The prompt is validated, it describes the exact structure, timing and easing, so the agent rebuilds the effect faithfully and you can then adapt colors, copy and layout to your design.

The full prompt

Anchored Card Step Scroll: Sticky Step Index, Cross-Fading Copy & a Phone Card That Swaps Layers

Goal

Build a single scroll-pinned "how it works" section on a white page. A tall corridor (400svh) holds a sticky stage of one viewport with three parts side by side: on the left a vertical step index (dot + label per step, joined by a thin line that fills from the top with scroll progress); in the middle a headline + paragraph for the current step, where each change is a cross-fade with a vertical shift (the outgoing block rises 25px and fades out, the incoming one comes up from +25px and fades in); and on the right a phone-sized card that stays anchored while its stacked UI layers cross-fade in step with the copy (the first layer is a photo with a title, the rest are dark app screens built in HTML). Everything is driven by one scrubbed GSAP timeline; the index does not animate on its own, it converts the scroll progress into "which step is active". GSAP + ScrollTrigger, native scroll (no smooth-scroll library).

Tech

Vanilla HTML/CSS/JS with ES module imports. gsap (npm) + ScrollTrigger. Fonts: Funnel Display (all text, weight 400), Overpass Mono (index labels).

Layout / HTML

<div class="ac">
  <section class="ac-steps" aria-label="How it works">
    <div class="ac-pin">
      <div class="ac-index" aria-hidden="true">
        <span class="ac-index__line"><b></b></span>
        <ol>
          <li class="is-active"><i></i><span>Create<br />a project</span></li>
          <li><i></i><span>Invite<br />the team</span></li>
          <li><i></i><span>Track<br />progress</span></li>
          <li><i></i><span>Ship<br />it</span></li>
        </ol>
      </div>

      <div class="ac-texts">
        <article class="ac-step"><h2>Start a project<br />in seconds</h2><p>Name it, pick a template and you are ready…</p></article>
        <article class="ac-step"><h2>Bring everyone<br />on board</h2><p>Invite people by email…</p></article>
        <article class="ac-step"><h2>See where<br />things stand</h2><p>Every task, owner and deadline on one screen…</p></article>
        <article class="ac-step"><h2>Ship when<br />it is ready</h2><p>Review the last details, press one button…</p></article>
      </div>

      <div class="ac-card" aria-hidden="true">
        <div class="ac-layer ac-layer--image">
          <p class="ac-layer__title">New<br />project</p>
          <img src="sphere.jpg" alt="" width="1000" height="1500" />
        </div>
        <div class="ac-layer ac-layer--dark">
          <p class="ac-layer__title">Team</p>
          <ul class="ac-people"><li><i>AM</i>Ana Molina<b>Owner</b></li> … 4 rows</ul>
          <span class="ac-button">Send invites</span>
        </div>
        <div class="ac-layer ac-layer--dark">
          <p class="ac-layer__title">Progress</p>
          <ul class="ac-bars"><li><span>Research</span><b style="--v: 100%"></b></li> … Design 80%, Build 55%, Review 20%</ul>
          <span class="ac-button">Open board</span>
        </div>
        <div class="ac-layer ac-layer--dark">
          <p class="ac-layer__title">Ready<br />to ship</p>
          <span class="ac-check">✓</span>
          <p class="ac-note">All checks passed</p>
          <span class="ac-button ac-button--light">Publish now</span>
        </div>
      </div>
    </div>
  </section>
</div>

There must be as many .ac-step articles, .ac-layer layers and index li items as steps (four here).

Styling

:root: --ac-paper:#ffffff, --ac-ink:#0a0b0f, --ac-muted:#5b6170, --ac-layer:#1c1f26, --ac-line:#2f333d, --ac-row:58px.

  • .ac: background:var(--ac-paper); color:var(--ac-ink); font-family:"Funnel Display".
  • .ac-steps: position:relative; height:400svh (the corridor; its height is how long the sequence lasts).
  • .ac-pin: position:sticky; top:0; height:100svh; overflow:hidden; display:grid; grid-template-columns:140px minmax(0,1fr) auto; align-items:center; column-gap:clamp(2rem,5vw,6rem); padding:0 clamp(2rem,6vw,7rem) 0 2.5rem.
  • Index: .ac-index relative. li: height:var(--ac-row); padding-left:22px, Overpass Mono 11px, uppercase, opacity:.45 → 1 for .is-active / .is-done (CSS transition .3s). li i: absolute dot 9px, border:1px solid currentColor; background:var(--ac-paper), filled (background:currentColor) when active or done. .ac-index__line: position:absolute; left:4px; top:5px; bottom:calc(var(--ac-row) - 5px); width:1px; background:rgba(10,11,15,.18); its b is the fill: inset:0; left:-1px; width:3px; background:currentColor; transform-origin:top; transform:scaleY(0).
  • Copy: .ac-texts: position:relative; height:18rem; max-width:34rem. .ac-step: position:absolute; inset:0; display:flex; flex-direction:column; justify-content:center. Rest state in CSS: .ac-step:not(:first-child){opacity:0}. h2: weight 400, clamp(2rem,4.4vw,4rem), line-height:1, letter-spacing:-.03em. p: margin-top:2rem; max-width:27rem; 1.05rem/1.55; color:var(--ac-muted).
  • Card: .ac-card: position:relative; height:min(70svh,500px); aspect-ratio:3/5; border-radius:10px. .ac-layer: position:absolute; inset:0; overflow:hidden; border-radius:inherit; background:#e6e8ec; box-shadow:0 30px 60px -30px rgba(0,0,0,.45); rest state: .ac-layer:not(:first-child){opacity:0}. Image fills the layer (object-fit:cover), title sits above it (z-index:2; padding:20px 24px; clamp(1.6rem,2.6vw,2.25rem)). .ac-layer--dark: background:var(--ac-layer); color:#fff; padding:4px 24px 0. People rows: flex, padding:11px 0; border-bottom:1px solid var(--ac-line), 28px round initials. Bars: 4px tall, linear-gradient(90deg,#fff var(--v), rgba(255,255,255,.14) var(--v)). .ac-button: absolute left/right/bottom:24px; height:42px; border:1px solid rgba(255,255,255,.8); border-radius:6px; --light variant white on ink.
  • @media (max-width:900px): --ac-row:46px; .ac-pin becomes grid-template-columns:14px minmax(0,1fr); grid-template-rows:auto 1fr; align-items:start; padding:4.5rem 1.25rem 2rem; the index spans both rows with the labels hidden (dots and line only); copy on top (.ac-texts{height:13.5rem}, paragraph margin 1rem); card centred below with height:min(48svh,420px) and tighter inner paddings.

GSAP effect (be exact)

gsap.registerPlugin(ScrollTrigger). Build in mount(config) → destroy().

const DEFAULTS = { stepGap: 1.05, shift: 25, fade: .3, scrub: .3 };

Timeline: tl = gsap.timeline({ defaults: { ease: "none" }, scrollTrigger: { trigger: ".ac-steps", start: "top top", end: "bottom bottom", scrub: .3, onUpdate } }).

For each step change i = 1 … n-1, at t = stepGap * i:

tl.to(steps[i-1], { opacity: 0, y: -shift, duration: fade }, t)
  .fromTo(steps[i], { opacity: 0, y: shift }, { opacity: 1, y: 0, duration: fade }, t + .08)
  .to(layers[i-1], { opacity: 0, duration: .25 }, t)
  .to(layers[i],   { opacity: 1, duration: .25 }, t);

Then tl.to({}, { duration: .5 }): a tail so the last step holds before the sticky stage releases. The incoming copy starts 0.08 after the outgoing one, so the two never sit fully on top of each other.

Index (in onUpdate(st)): gsap.set(lineFill, { scaleY: st.progress }); active step = the largest i with st.progress * tl.duration() >= stepGap * i (0 if none); toggle .is-active on that li and .is-done on every earlier one. Use the scroll progress, not tl.time(): with scrub the timeline lags behind the scroll, and onUpdate stops firing when the scroll stops, so reading the timeline would leave the index one step behind.

destroy(): kill the ScrollTrigger and the timeline, clearProps:"all" on steps, layers and the line fill, reset the index to the first item.

Assets / images

One portrait photo (2:3, ~1000×1500) for the first card layer: an object on a light, plain backdrop with empty space at the top, because the layer title is set in dark ink over it.

Behavior notes

  • The pin is plain CSS position: sticky inside a tall section, not ScrollTrigger pin; nothing is re-parented and no pin spacer is added.
  • The rest state lives in the CSS (step 1 and layer 1 visible), so without JS the section still reads.
  • To add or remove a step, keep the three lists in sync (article, layer, index item); the timeline and the index derive everything from steps.length.
  • Only the prefixed variables are global.

Images

This component ships with 1 reference asset, served publicly. Use it as-is to reproduce the demo faithfully, then swap in your own: the layout expects the same aspect ratio.

https://motionprompts.dev/c/anchored-card-step-scroll/sphere.jpg

It is hotlinkable for prototyping. For anything you ship, replace it: it is licensed for demonstration of this component, not for redistribution.

Using this outside its demo page

This component is written as a complete page: that is how the demo is meant to look. If you are dropping it into an existing project, or combining it with other components, these are the things it declares at document level and that you need to move or reconcile first.

  • Palette on :root: --ac-paper, --ac-ink, --ac-muted, --ac-layer, --ac-line, --ac-row. Generic names like --ink, --paper or --muted are defined by many components in this catalogue with different values, and they will also collide with whatever your own project defines. Move them onto the component's wrapper (.my-section { --ink: … }) or keep the prefix.
  • **Rules on *, *::before, *::after, html, body**: the demo owns the whole document, so these set the box model and resets. Dropped into an existing project they restyle the entire page, not just this section. Re-target them at the component's wrapper before using it.

New components in your inbox

One email a week, only when new components ship, each with its live demo and prompt.