
The elastic button
Buttons, Hover, Text
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».
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>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
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 siteThe 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.
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 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.
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.
| Name | File | Default | What it changes |
|---|---|---|---|
START | script.js | 2 | The starting quantity. |
MAX | script.js | 10 | The maximum quantity per order: beyond it, the plus shakes. |
PRICE | script.js | 18 | The price of one item. |
FREE_SHIPPING | script.js | 50 | From which total shipping is free. |
HOLD_SPEED | script.js | 0.8 | How much holding speeds up: lower is faster. |
ROLL_TIME | script.js | 0.42 | The seconds a digit takes to roll into the next. |
ACCENT | script.js | #4f46e5 | The colour of the flash on the total and of the limit. |
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.
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.
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.
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.
Tested on 5 November 2026
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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.