Skip to content
motionprompts motionprompts

Inline Pill Odometer Sentence

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

Open live demo ↗ Raw prompt (.md)

What it does

Large sentence with inline data pills: a solid pill holds a number that rolls like an odometer (each digit a vertical 0 to 9 column, two turns, columns braking left to right) when the sentence enters the viewport, while every pill scales up from 0.8 in a cascade. A Replay button runs it again.

How it's built

Categorytext
Techgsap
GSAP pluginsScrollTrigger
Complexitysection
Performance costlight
Mobile-safeyes

odometer counter pills inline sentence number-roll scrolltrigger 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 Odometer Sentence: Data Pills Inside a Sentence and a Rolling Odometer Number

Goal

Build a white full-viewport section with one large black sentence that has data pills inline with the words: *"Your account starts earning [● Yield 4,500 €] and then you decide to [save 40 %], [invest 40 %] and [give 20 %]"*. The first pill is solid black and holds a number that rolls like an odometer: each digit is a vertical column of 0 to 9 that spins two turns and lands on its digit, the columns braking one after another from left to right. At the same time every pill scales up from 0.8 (and from 40 % opacity) in a short cascade. It plays once when the sentence enters the viewport and a Replay button below runs it again.

Tech

Vanilla HTML/CSS/JS with ES module imports. gsap (npm) and gsap/ScrollTrigger. Fonts: Schibsted Grotesk (400/500) and JetBrains Mono for the number.

Layout / HTML

<div class="po">
  <section class="po-stage">
    <p class="po-sentence" data-po-sentence>
      Your account starts earning
      <span class="po-pill po-pill--solid"><i class="po-dot" aria-hidden="true"></i><small>Yield</small> <b class="po-odo" data-po-odo data-value="4500">4,500</b> €</span>
      and then you decide to
      <span class="po-pill">save 40 %</span>,
      <span class="po-pill po-pill--outline">invest 40 %</span>
      and
      <span class="po-pill po-pill--outline">give 20 %</span>
    </p>
    <button class="po-replay" type="button" data-po-replay>Replay</button>
  </section>
</div>

Styling

:root: --po-bg:#fff, --po-ink:#0a0a0a, --po-pill:#ececec, --po-accent:#0a0a0a (solid pill and outlines), --po-size:clamp(1.9rem,4.6vw,4.4rem).

  • .po-stage: min-height:100svh, flex column centred vertically, items at the start, gap:2.5rem, padding:clamp(1.25rem,7vw,8rem).
  • .po-sentence: max-width:22ch (none under 560px), --po-size, weight 500, line-height:1.32, letter-spacing:-.035em.
  • .po-pill: display:inline-flex; align-items:center; gap:.25em; padding:.02em .45em; border-radius:999px; background:var(--po-pill); line-height:1.15; white-space:nowrap; transform-origin:50% 60%.
  • .po-pill--outline: transparent with box-shadow:inset 0 0 0 .06em var(--po-accent).
  • .po-pill--solid: background:var(--po-accent); color:var(--po-bg); padding-left:.14em; height:1.25em; vertical-align:-.12em. Its small is .42em, 70 % opacity. .po-dot: a 1em white circle.
  • .po-odo: display:inline-flex, JetBrains Mono 400, letter-spacing:-.06em, tabular numerals, height:1.15em; line-height:1.15em; overflow:hidden. .po-digit: inline-block; height:1.15em; overflow:hidden; its inner spans display:block.
  • .po-replay: outlined pill, inverts on hover/focus.

GSAP effect (be exact)

Build in mount(config) → destroy().

const DEFAULTS = { duration: 1.2, columnDelay: 0.15, pillStagger: 0.06 };

Building the odometer: read data-value, format with toLocaleString("en-US") ("4,500"), set it as aria-label, and rebuild the <b>: for each non-digit a plain .po-sep span; for each digit a .po-digit holding an inner span with 20 rows (0…9 twice). All built spans are aria-hidden.

Row height: firstRow.offsetHeight, not getBoundingClientRect(), because the pill is at scale(.8) before it enters and the scaled height would land the columns on the wrong digit.

play(): timeline at 0:

  • fromTo(pills, { scale: .8, opacity: .4 }, { scale: 1, opacity: 1, duration: .5, stagger: pillStagger, ease: "back.out(2)" });
  • for column j: fromTo(inner, { y: 0 }, { y: -(10 + digit) * rowH, duration: duration + j * columnDelay, ease: "power3.out" }) at .1. Landing on the second turn makes every digit spin a full lap first; the growing duration makes the columns stop left to right.

Before it plays, pills sit at scale:.8; opacity:.4 and digits show 0. ScrollTrigger.create({ trigger: sentence, start: "top 85%", once: true, onEnter: play }). Replay calls play() again. On resize after playing, re-set the columns to their final y.

prefers-reduced-motion: reduce: pills at full size, columns set straight to their final digit.

destroy(): kill the trigger and timeline, remove listeners, clearProps on the pills, restore the plain number text.

Assets / images

None.

Behavior notes

  • Separators (commas) are static characters between columns, so any value works: change data-value.
  • The odometer window is 1.15em with overflow:hidden, sized in the pill's own em, so it scales with --po-size.
  • Pills are inline-flex inside running text: the sentence wraps naturally on mobile.
  • 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: --po-bg, --po-ink, --po-pill, --po-accent, --po-size. 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.