Skip to content
animorio
IT
Back to the library

Numbers that count up and widen

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

Text, ScrollGSAPEasyLifetime

Scroll inside the preview

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN.

The code for this animation is part of lifetime access.

The preview stays open: watch it, slow it down, try it on your phone.

Lifetime access

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.

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.

Weight: 4.6 KB of our own files.

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