04.34 · Micro-Interactions

Rolling Numbers

Each digit rolls to its new value, like a mileage counter. Best for prices.

Click it

Click or tap −1, +1 or Random to change the number (Reset brings it back), or press Show me.

Visitors today

2,048

Try it

Change a setting, then try it again or press Show me.

Roll speed

How long a digit takes to roll to its new value.

Direction

Up turns every digit forward like a mileage counter; shortest takes the nearer way round.

Each digit starts a moment after the one to its right.

Copy the prompt

Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.

Add rolling numbers to [the number that changes, such as a counter, score or price]. Show each digit in a small window over a column of the digits 0 to 9, and when the value changes, slide each column so its new digit rolls into view, like the wheels of a mileage counter; digits that stay the same do not move, and separators stay still. Give every digit the same width so the number never shifts sideways, and only slide the columns, never resize anything, so it stays smooth. Let screen readers hear the plain number once. If the visitor has reduced motion turned on, swap the digits with a short fade instead of rolling. Match the settings listed below.

Replace the words in brackets with your own element. Your settings are added at the end.

Free and open source. If this helped, a star on GitHub helps other people find it.

Star on GitHub

What it is

The full explanation is in README.md.

Good for

  • Counters
  • Prices
  • Scores
  • Dashboards

Avoid on

  • Numbers that change every second
  • Long decimals