Skip to content
IndexRequest a UIAboutContact

Rolling Counter

A number whose digits roll vertically to the new value when it changes.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Build a quantity stepper with a minus button, a number display and a plus button. The display shows a value from 0 to 999 in 40px semibold tabular figures using three digit columns; each column is a 1em tall window with overflow hidden containing a vertical stack of the digits 0 to 9. When the value changes set each column's translateY to minus its digit times 1em with a 320ms cubic-bezier(.3,.9,.3,1) transition, delaying the less significant digits by 30ms each. Hide leading zeros by fading the column to opacity 0 when it is a leading zero. Buttons are 44px circles, disabled at 0 and 999. Holding the plus or minus button repeats after 400ms every 80ms. Put aria-hidden on the columns and show the number in a visually hidden element with role status. Under prefers-reduced-motion remove transitions.

About this pattern

Definition

A numeric display where each digit sits in a column of 0 to 9 and slides to the target digit when the value changes, like an odometer.

Purpose & UX principles

  • Makes change visible and gives a sense of direction (up or down).
  • Suited to quantities, scores and prices that update in place.
  • The visual columns are hidden from assistive technology; a live region reads the plain number.

Interaction states

  • Idle, rolling, minimum and maximum (buttons disabled), focus-visible on the buttons.

Motion specification

  • Each digit column translates 320ms cubic-bezier(.3,.9,.3,1); lower digits start 30ms later for a cascade.
  • Reduced motion: digits switch instantly.

Responsive behaviour

  • Sized in em units so it scales with the font size.
  • Minus and plus buttons are 44px.

Code

HTML
<div class="stepper">
  <button id="m" aria-label="Decrease">−</button>
  <div class="num" aria-hidden="true" id="num"></div>
  <span class="sr" role="status" id="sr">12</span>
  <button id="p" aria-label="Increase">+</button>
</div>

Related patterns

Range Slider

↗
Range SliderInputs & Forms

Progress Indicator

↗
Progress IndicatorLoading & Progress

Icon Button

↗
Icon ButtonButtons & Actions