Skip to content

Animated Number Counters

Stats section with four number cards that count up when scrolled into view, using IntersectionObserver, locale formatting and reduced-motion support.

Also known as: count up numbers, animated statistics section, number counter animation, stats counter on scroll

Animated Number Counters live demo

Open in new tab

Pure CSS code (HTML, CSS, JS)

A statistics section with four number cards that count up from zero the first time they scroll into view. It is built with pure CSS and a small vanilla JavaScript file using IntersectionObserver and requestAnimationFrame, and works well on landing pages, about pages and annual report summaries.

How it works

The root section.ac-stats holds a centered .ac-head and a ul.ac-grid of li.ac-item cards. Each card has an .ac-icon, a p.ac-number and a .ac-label. Inside the number, .ac-value is the animated text and carries the settings as data attributes: data-target, data-decimals, data-prefix and data-suffix. The markup already contains the final values, so the section reads correctly without JavaScript.

On DOMContentLoaded the script initializes every .ac-stats. It adds .ac-ready to the root, resets each .ac-value to zero and observes it with an IntersectionObserver (threshold 0.6). When a value becomes visible it is unobserved, so each counter runs only once. A requestAnimationFrame loop with an ease-out cubic curve updates the text, formatted with toLocaleString() so thousands separators and decimals stay consistent. At the same moment the card receives .is-counted, and the colored bar at its bottom edge grows from left to right in sync with the number. font-variant-numeric: tabular-nums keeps the digits from wobbling while they change.

The grid shows one column on phones, two from 520px and four from 960px.

Customization

  • data-target, data-decimals, data-prefix and data-suffix on each .ac-value: the final number and how it is written, e.g. data-prefix="$" with data-suffix="M". Update the static text and the .ac-sr text to match.
  • data-duration="2000" on .ac-stats: how long every count takes, in milliseconds; the bottom bar uses the same duration.
  • data-locale="en-US": the number format; de-DE gives 12.500.
  • .ac-item--teal, .ac-item--lime, .ac-item--coral and .ac-item--violet: each sets --ac-color for the icon tile and the bottom bar. Add your own modifier for a new color.
  • --ac-bg, --ac-card and --ac-radius on .ac-stats: page background, card background and corner radius.
  • Change threshold: 0.6 in script.js to start counting earlier or later while scrolling.

Use cases

  • Landing pages: four number cards count up from zero when they first scroll into view
  • About pages: figures like customers, projects and years in business get attention
  • Annual report summaries: locale formatting displays large figures clearly in four compact number cards
  • Accessible sites: reduced-motion support shows final values without the animation

Accessibility

The changing digits in .ac-value are aria-hidden="true", and each number has a visually hidden .ac-sr twin with the final value in plain words, for example "4.9 out of 5". Screen readers therefore hear one stable value instead of a stream of intermediate numbers. Icons are decorative and hidden from assistive technology. When prefers-reduced-motion: reduce is set, the script leaves the final values in place, does not animate and shows the bars at full width. Text colors meet WCAG AA contrast on the white cards.

Usage notes

Several stat sections can share a page; each one has its own observer and settings. Browsers without IntersectionObserver simply show the final values.

Animated Number Counters at a glance

Framework
Pure CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
None
Layout
Responsive, works on mobile
Category
Stats Sections
License
Free for personal and commercial use

Questions about this template

Can I use the Animated Number Counters code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

There is nothing to install. Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

No dependencies. Pure HTML, CSS and JavaScript.

Animated Number Counters – free Pure CSS stats section template
Animated Number Counters · free Pure CSS stats section template

More Stats Sections

Stats with Circular Progress Rings – free Pure CSS stats section template

Stats with Circular Progress Rings

Dark stats section with four SVG circular progress rings that fill and count up to their percentage when scrolled into view.

Stats Section with Background Image – free Bootstrap 5 stats section template

Stats Section with Background Image

Bootstrap 5 stats section with four key numbers in glass cards over a darkened background photo, with a count-up animation on scroll.

Stats Section with Count-Up Numbers – free Tailwind CSS stats section template

Stats Section with Count-Up Numbers

Tailwind CSS key-metrics section on an emerald brand background with large numbers, labels, trend notes and an accessible count-up on scroll.

Stats Section with Four Key Numbers – free WordPress stats section template

Stats Section with Four Key Numbers

A dark stats section with four key numbers, labels and short notes, a statistics counter band for Gutenberg that highlights company figures.