DataPremium

Animated Stat Counter

Plain tiles where only the figures move: each value climbs to its target at its own pace and counts again from the displayed figure when data changes.

JSrAFEasing

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Data has 28 effects, including 1 free. Explore the category →

3 usage examples

A tool library's results, year by year — "Our figures" page — Animated Stat Counter example 1

① A tool library's results, year by year — "Our figures" page

WhenOn the "Our figures" page of a tool-lending service, three buttons 2024, 2025, 2026 sit above three tiles: loans, tools on the shelves, members. Each click slides the three figures from the displayed year to the chosen one.
WhyThe figure restarts from the previous value, not from zero: you see the progress from one year to the next (1,815 loans, then 2,390) instead of three tables to compare in your head.
Settings--stco-max:100%, white tiles (--stco-item:#fff, --stco-border:#dfe4dc), --stco-color:#1d5c45, value at 31 px, data-duration from 900 to 1,100 ms. The year buttons write the three data-target attributes; in the scene, a click outside the buttons moves to the next year.
A household's water use by number of occupants — a water board's estimator — Animated Stat Counter example 2

② A household's water use by number of occupants — a water board's estimator

WhenAn estimator asks how many people live in the home, with a slider from 1 to 6. Below it, three tiles give litres per day, cubic metres per year and the estimated bill; they follow the slider.
WhyA computed result reads better when you watch it move with the setting: going from 3 to 5 people pushes the three figures up together, the bill last under your eyes.
Settingsdata-suffix "L", "m³" and "€", data-duration="600" to keep up with the gesture, --stco-color:#0b78b6, value at 25 px. The slider's input event recomputes and writes the three targets; in the scene, a click outside the slider adds one person.
Key figures of a new tram line in the margin of a local newspaper article — Animated Stat Counter example 3

③ Key figures of a new tram line in the margin of a local newspaper article

WhenIn the margin of an article about a tram line opening, a "Key figures" box stacks three tiles: 9.6 km of track, 14 stops, 22,000 riders expected daily. They count when the reader reaches them.
WhyIn a long text, three still figures get skipped. Counting catches the eye once, with no moving frame and no loud colour: the box stays part of the article.
Settings--stco-max:158px (one tile per row), data-target="9.6" with data-suffix=" km", beige tiles #f1eee6, black figures, value at 23 px. In the scene, the article scrolls by itself on the first pointer move to bring the box on screen.

How it works

Each .stco-item tile holds a .stco-value and its label. The target lives in data-target, the duration in data-duration (1,500 ms when the attribute is missing): in the demo, the three values stop at 1.2 s, 1.8 s and 2 s. The tiles themselves are in place from the start: nothing pops in, nothing bounces.

The script waits until the grid is half visible, then raises each value, slowing down as it nears the target. The number is written by Intl.NumberFormat in the page language: "48,210" under lang="en", "48 210" under lang="fr". data-prefix and data-suffix add a currency or a unit; a dot in data-target ("9.6") sets the number of decimals.

Changing data-target later restarts the count from the displayed figure, upwards or downwards: a period filter or a slider only has to write the new value into the attribute. A change that lands mid-count takes over without a jump.

The grid lays the tiles out in equal columns at least 110 px wide (auto-fit) within the --stco-max width: three abreast in 380 px, two in 250 px, a single one in a 158 px margin.

Accessibility

  • Screen readers: the moving figure is aria-hidden; a hidden .stco-sr text, added by the script, carries the end value with its prefix and suffix. It is rewritten on every data-target change.
  • Reduced motion: no climb; the end value is written straight away, including when a value changes.
  • Without JavaScript: the text written in the HTML ("48,210") stays displayed as is. Keep the real value there, not a zero.
  • Unannounced change: no aria-live region. If a filter changes the figures, leave focus on the button used or announce the change yourself.
  • Contrast: by default, light violet #a78bfa on a near-black background. On a light background, change --stco-color and --stco-muted.

Browser compatibility

CSS grid auto-fit, IntersectionObserver, MutationObserver, Intl.NumberFormat, requestAnimationFrame. Same readings in Chromium 149, Firefox 151 and WebKit 26.5: values at 0 while the grid is off screen, exact landing on 48,210, $126,400 and 18%, and when two blocks share the page, only the one whose data changes counts again.

Chrome 57+✓ Full (measured)
Firefox 55+✓ Full (measured)
Safari 12.1+✓ WebKit engine measured, not checked in real Safari
Edge 79+✓ Full (Chromium engine)
Safari iOS 12.2+✓ Not checked on a real device
Chrome Android 57+✓ Full (Chromium engine)

Without IntersectionObserver, counting starts on page load. Without CSS grid, the tiles stack across the full width. Without JavaScript, the values written in the HTML stay displayed and still.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0247-root">
  <div class="stco-grid">
    <div class="stco-item">
      <div class="stco-value" data-target="48210" data-duration="1800">48,210</div>
      <div class="stco-label">Users</div>
    </div>
    <div class="stco-item">
      <div class="stco-value" data-target="126400" data-prefix="$" data-duration="2000">$126,400</div>
      <div class="stco-label">Revenue</div>
    </div>
    <div class="stco-item">
      <div class="stco-value" data-target="18" data-suffix="%" data-duration="1200">18%</div>
      <div class="stco-label">Growth</div>
    </div>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
data-target (HTML) 48210, 126400, 18 End value; a decimal point sets how many decimals are shown. Changing it restarts the count.
data-duration (HTML) 1800, 2000, 1200 Climb time in milliseconds, one per value (1,500 without the attribute).
data-prefix, data-suffix (HTML) "$" and "%" in the English demo Text attached before or after the number: currency, unit, sign. Any space is part of the attribute.
lang on the page or a parent (HTML) browser language Number format: thousands comma or space, decimal point or comma.
--stco-color (CSS) #a78bfa Flat colour of the values.
--stco-item, --stco-border (CSS) indigo at 8% and 15% Tile background and border.
--stco-muted (CSS) white at 50% Label colour.
--stco-max (CSS) 380px Maximum grid width; together with the 110 px minimum per tile, it decides the number of columns.
--stco-bg (CSS) #0a0a0f Block background; transparent to use the page's own.

FAQ

The counting is the same; the entrance is what changes. In Stat Cards, the cards are invisible and then pop in one after another with a slight bounce, and the figures use a gradient. Here the tiles are in place from the start, in one flat colour, on a grid of equal columns: only the figures move. Pick this one for a dashboard or an article, Stat Cards for a showier arrival.
The value never wraps. In the original grid (three tiles in 380 px), a nine-character value such as "126 400 €" only just fits and an eleven-character one sticks out by a few pixels. Widen --stco-max, reduce the .stco-value size (1.5rem originally) or shorten the number: data-target="1.26" with data-suffix="M".
Write the new value into the attribute: el.setAttribute('data-target', 2390). The script watches data-target, data-prefix and data-suffix on each value. If the grid has not been seen yet, the figure stays at 0 and will climb to the last target written.