Skip to content
animorio
IT
All components

Rolling quantity stepper

Counters, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.8 KBGSAP 28 KBFreeDownload the zip

An interface component in the style of product micro-interactions, Press gesture, on very light grey: a cart line with a real photo of a stoneware mug from an invented shop and a pill-shaped quantity stepper. Pressing plus or minus rolls the digit the right way and the subtotal rolls with it, digit by digit; holding speeds it up. At 1 the minus turns into a bin that closes the line and leaves «Undo», at the maximum the plus gives a small shake and says «Max 10 per order».

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Rolling quantity stepper" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>The quantity stepper with rolling digits</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage" data-stage>
    <!-- one line of a cart: the stepper rolls its digit up or down, the subtotal rolls with it,
         at 1 the minus becomes a bin, at the maximum the plus shakes -->
    <section class="cart" data-card aria-label="Cart">
      <div class="cart__body" data-body>
        <div class="item" data-item>
          <div class="item__thumb" aria-hidden="true">
            <img class="item__photo" src="tazza.webp" width="360" height="360" alt="" decoding="async">
            <span class="item__shine"></span>
          </div>
          <div class="item__text">
            <p class="item__name">Stoneware mug</p>
            <p class="item__meta">Brennet · Ash · 350 ml</p>
            <p class="item__price" data-unit>€18.00</p>
          </div>
          <div class="stepper" data-stepper role="group" aria-label="Quantity">
            <button class="step step--minus" type="button" data-minus aria-label="Decrease quantity">
              <span class="step__face"></span>
              <svg class="step__icon step__icon--minus" data-icon-minus viewBox="0 0 20 20" aria-hidden="true"><path d="M5.5 10h9"></path></svg>
              <svg class="step__icon step__icon--bin" data-icon-bin viewBox="0 0 20 20" aria-hidden="true">
                <path class="bin__lid" d="M4.5 6h11M8.2 6V4.6c0-.5.4-.9.9-.9h1.8c.5 0 .9.4.9.9V6"></path>
                <path d="M6 6.2l.7 9.1c.1.8.7 1.4 1.5 1.4h3.6c.8 0 1.4-.6 1.5-1.4l.7-9.1M8.6 9v4.8M11.4 9v4.8"></path>
              </svg>
            </button>
            <output class="qty" data-qty aria-live="polite">2</output>
            <button class="step step--plus" type="button" data-plus aria-label="Increase quantity">
              <span class="step__face"></span>
              <svg class="step__icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M5.5 10h9M10 5.5v9"></path></svg>
            </button>
          </div>
        </div>
        <div class="cart__foot">
          <p class="hint"><span class="roll" data-hint><span class="roll__in">Free shipping over €50</span></span></p>
          <p class="total"><span class="total__label">Subtotal</span> <span class="total__num" data-total>€36.00</span></p>
        </div>
      </div>
      <div class="removed" data-removed aria-hidden="true">
        <span class="removed__text">Removed · Stoneware mug</span>
        <button class="undo" type="button" data-undo tabindex="-1">Undo</button>
      </div>
    </section>
    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></svg>
  </main>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

25 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Rolling quantity stepper” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On a very light grey background there is a white card with one cart line: the soft-cornered square thumbnail with a photo of a stoneware mug in an ash-white glaze, its bare clay foot showing, on a wooden table, «Stoneware mug», «Brennet · Ash · 350 ml» and the unit price, and on the right a grey pill stepper with two round white keys and the digit in the middle. Below a thin rule sit «Free shipping over €50» and the subtotal. Pressing plus sinks the key and springs it back, the new digit rises from below as the old one leaves at the top, and the subtotal does the same digit by digit, from the right, with an indigo flash that fades; a highlight slides across the photo of the mug. Minus rolls everything downwards. Holding a key keeps the quantity going on its own, faster and faster. Above 50 euros the line below rolls into «Free shipping unlocked». At 10 the plus dims a little: pressed again, the stepper gives a shake of a few pixels and the line says «Max 10 per order». Going down to 1 the minus turns and becomes a bin, its lid lifting for a moment; pressed, the line fades, the card closes with a spring into a single row, «Removed · Stoneware mug», with «Undo» to bring it back. A drawn pointer does it all by itself and starts again.

How it works

One slot per character

The digit and the subtotal are written character by character, each in a slot that clips what leaves. When a character changes, the old one goes up (or down) and the new one comes in from the other side with back.out: only the changed characters roll, from the right, 35 milliseconds apart.

Press and hold

On press one step is taken and gsap.delayedCall is scheduled: at each repeat the interval is multiplied by HOLD_SPEED down to 70 milliseconds. Releasing the key, or a refused step (at the maximum, or at 1 while holding minus), stops the repeat.

The minus that becomes a bin

The key holds two icons on top of each other: at 1 the minus turns 90 degrees and fades, the bin comes in turning from 18 degrees with back.out and its lid gives a small elastic flick. Only a fresh press on the bin removes the line, never the repeat.

Closing and reopening the card

The card takes its height in pixels, the content fades and the height drops to 52 with a spring, where the «Removed» row with Undo appears. To reopen it the real height is measured with height auto, set back to the previous one and animated to the real one, then the fixed height is cleared.

Values to change

NameFileDefaultWhat it changes
STARTscript.js2The starting quantity.
MAXscript.js10The maximum quantity per order: beyond it, the plus shakes.
PRICEscript.js18The price of one item.
FREE_SHIPPINGscript.js50From which total shipping is free.
HOLD_SPEEDscript.js0.8How much holding speeds up: lower is faster.
ROLL_TIMEscript.js0.42The seconds a digit takes to roll into the next.
ACCENTscript.js#4f46e5The colour of the flash on the total and of the limit.

Try them in the Playground

When to use it

In the cart or on the product page of an online shop, for the quantity of an item, tickets or covers: it shows straight away how much you spend, warns about the limit and lets you undo a removal.

On phones

The card takes the width of the box minus the margins, the thumbnail shrinks and the keys stay big enough for a finger; under 380 pixels the brand line goes away. Holding with a finger speeds up like with a mouse.

With reduced motion

Digits change with a fade instead of rolling, no shake and no highlight on the mug, the card closes and reopens without a spring and the drawn pointer stays hidden.

Pitfalls

  • A mouse click fires both pointerdown and click: the step is taken on pointerdown and click only counts with detail 0, that is from the keyboard, otherwise every press would count twice.
  • The repeat must never remove the line: holding minus stops at 1, and the bin only works with a fresh press.
  • When the number goes from one digit to two (9 to 10) the slots change count: they are all rebuilt and roll together, instead of one by one.
  • The pilot uses gsap.delayedCall and a timeline, never setTimeout: so the preview bench also drives the repeat.
  • The thumbnail is a real photo in a square box with overflow hidden and round corners: the image fills it with object-fit cover and an object-position slightly low, so the mug stays centred; the highlight and the hairline border sit above the photo, in separate elements.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.8 KB; the libraries: GSAP 28 KB.

Testing

Tested on 5 November 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 components