Skip to content
motionprompts motionprompts

Inline Pill Headline Preloader

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

Open live demo ↗ Raw prompt (.md)

What it does

Full-screen preloader that counts from 00 to 100 and lifts away (yPercent -100). As it leaves, the three lines of a condensed uppercase headline rise from their masks and a rounded image pill set at the start of the second line opens from zero to its width, pushing the words aside. A small button replays the sequence.

How it's built

Categorypreloader
Techgsap
Complexitypage
Performance costlight
Mobile-safeyes

preloader counter headline mask-reveal image-pill inline-image intro typography

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

Inline Pill Headline Preloader: 00 to 100 Counter That Lifts Into a Masked Headline With an Opening Image Pill

Goal

Build a white page with a full-screen black preloader on top showing a large counter that runs from 00 to 100, then lifts away upward (yPercent:-100). As it leaves, a giant condensed uppercase headline of three lines appears: each line rises out of its own mask, and a rounded image pill placed at the start of the second line opens from zero width to its full width, pushing the words to the right. A small, discreet Replay button in the corner runs the whole sequence again. GSAP only.

Tech

Vanilla HTML/CSS/JS with ES module imports. gsap (npm), no plugins. Fonts: Sofia Sans Extra Condensed 800 (counter and headline) and Hanken Grotesk 500 (button).

Layout / HTML

<div class="ip">
  <div class="ip-loader" data-ip-loader aria-hidden="true">
    <span class="ip-count" data-ip-count>00</span>
  </div>
  <section class="ip-stage">
    <h1 class="ip-title" aria-label="We make work that people look at">
      <span class="ip-mask"><span>We make</span></span>
      <span class="ip-mask"><span><span class="ip-pill" data-ip-pill><img src="/c/inline-pill-headline-preloader/pill.jpg" alt="" width="280" height="180" /></span>work that</span></span>
      <span class="ip-mask"><span>people look at</span></span>
    </h1>
    <button class="ip-replay" type="button" data-ip-replay>Replay</button>
  </section>
</div>

Styling

:root: --ip-bg:#fff, --ip-ink:#0d0a10, --ip-size:clamp(4.2rem,12vw,11rem), --ip-pill-w:1.08em.

  • .ip-loader: position:fixed; inset:0; z-index:10; background:var(--ip-ink); color:var(--ip-bg); counter bottom right, padding:clamp(16px,3vw,40px).
  • .ip-count: Sofia Sans Extra Condensed 800, font-size:clamp(5rem,18vw,16rem); line-height:.8; font-variant-numeric:tabular-nums.
  • .ip-stage: min-height:100svh; display:flex; align-items:center, side padding as above.
  • .ip-title: Sofia Sans Extra Condensed 800, font-size:var(--ip-size); line-height:.86; letter-spacing:-.01em; text-transform:uppercase.
  • .ip-mask: display:block; overflow:hidden; padding-bottom:.06em; margin-bottom:-.06em (room for descenders without opening the mask). .ip-mask > span: display:flex; align-items:center; gap:.1em; white-space:nowrap.
  • .ip-pill: flex:none; width:var(--ip-pill-w); height:.66em; border-radius:999px; overflow:hidden; transform:translateY(-.03em); the img covers it (object-fit:cover). Sized in em, so it scales with the headline.
  • .ip-replay: absolute bottom right, 0.8rem uppercase, 1px currentColor border, pill radius, opacity:.55 (1 on hover).
  • Under 767px: --ip-size:clamp(3.2rem,15vw,6rem), --ip-pill-w:1.3em, pill height:.7em.

GSAP effect (be exact)

Build in mount(config) → destroy().

const DEFAULTS = { count: 1.1, lift: .8, overlap: .45, lines: 1.05, stagger: .09, pill: 1.0, pillAt: .35 };

play() (called on mount and by the button; kills the previous timeline first):

  1. Reset: counter text "00", gsap.set(loader, { yPercent: 0, autoAlpha: 1 }), gsap.set(lines, { yPercent: 105 }), gsap.set(pill, { width: 0 }).
  2. intro timeline: .to(lines, { yPercent: 0, duration: 1.05, stagger: .09, ease: "power4.out" }, 0) and .to(pill, { width: "1.08em", duration: 1, ease: "power4.inOut" }, .35). The width is read from --ip-pill-w so the mobile value applies.
  3. Master timeline: .to({ v: 0 }, { v: 100, duration: 1.1, ease: "power2.inOut", onUpdate: write String(Math.round(v)).padStart(2,"0") }), then .to(loader, { yPercent: -100, duration: .8, ease: "power4.inOut" }, "+=0.1"), then .add(intro, "-=0.45") so the headline starts rising while the overlay is still leaving.

If prefers-reduced-motion: reduce matches, hide the loader and set everything to its final state.

destroy(): remove the button listener, kill the timeline, clearProps:"all" on loader, lines and pill.

Assets / images

One image, /c/inline-pill-headline-preloader/pill.jpg (560×360, JPEG): two people in a bright studio. Any photo works; it is cropped by object-fit:cover into the pill.

Behavior notes

  • The pill animates width, not scale, so the rest of the line is pushed along as it opens.
  • Use yPercent on the inner spans and keep the rest position in CSS at 0; masks are the overflow:hidden wrappers.
  • Only the prefixed variables are global.

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: --ip-bg, --ip-ink, --ip-size, --ip-pill-w. 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.