Skip to content
animorio
IT
Back to the library

Widening count-up

Text, ScrollGSAPEasyCompressed weight: Demo 2.2 KBGSAP + ScrollTrigger 45 KBFreeDownload the zip

Scroll inside the preview

The classic counter, except the number also grows in width: from narrow and nervous to full and steady, with a trailing shadow.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Widening count-up" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="it">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Numeri che contano e si allargano</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/standard.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main>
    <section class="intro">
      <h1>Qualche numero</h1>
      <p>Scorri: i numeri contano e intanto si allargano.</p>
    </section>

    <!-- data-fino: il numero d'arrivo. Il testo iniziale resta per chi non ha JavaScript -->
    <ul class="numeri">
      <li><span class="numero" data-fino="128">128</span><span class="cosa">progetti consegnati</span></li>
      <li><span class="numero" data-fino="36">36</span><span class="cosa">città dei clienti</span></li>
      <li><span class="numero" data-fino="9">9</span><span class="cosa">premi di design</span></li>
      <li><span class="numero" data-fino="2014">2014</span><span class="cosa">l'anno del primo sito</span></li>
    </ul>

    <section class="coda" aria-hidden="true"></section>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/ScrollTrigger.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

23 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Widening count-up” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

When a number enters the screen it counts up to its value. At the same time it widens along the font's width axis and an offset shadow grows with it. Years start from a little earlier, not from zero.

How it works

An object to animate

GSAP does not animate the text of a number: it animates an object { v, w, s } and on every update writes the rounded value, the width and the shadow offset into the DOM.

Equal-width digits

font-variant-numeric: tabular-nums gives every digit the same width, so the number does not jiggle while counting.

Width as a variable

The CSS uses font-stretch: calc(var(--w) * 1%). JavaScript only changes --w: no heavy layout work beyond the text itself.

Replays when scrolling back

toggleActions 'play none none reset' restarts the animation when you scroll back above its start. To play it once, use once: true.

Values to change

NameFileDefaultWhat it changes
data-finoindex.html128, 36, 9, 2014The final value of each number.
DURATAscript.js2.2Seconds of counting.
LARGHEZZAscript.js75, 104Font width at the start and at the end (wdth axis).
SCIAscript.js12Maximum shadow offset in pixels. Zero removes it.
--numero, --sciastyle.css#ff8a3dColour of the number and of its shadow.

Try them in the Playground

When to use it

For numbers that are real data: years, quantities, results. Not for numbering sections or menu items.

On phones

The same. Below 760 pixels the grid switches to two columns.

With reduced motion

The numbers are already at their value and final width, with no counting.

Pitfalls

  • If the font has no width axis, font-stretch does nothing: check that it is a variable font with wdth.
  • Keep the final number written in the HTML: it is what search engines and people without JavaScript read.

Libraries

GSAP 3.15.0, ScrollTrigger 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 2.2 KB; the libraries: GSAP + ScrollTrigger 45 KB.

Testing

Tested on 26 September 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations