
The elastic button
Buttons, Hover, Text
The balance of a travel eSIM app, on the palest grey: you pick an amount and a white pill snaps under it with a bounce, while the figure on the «Top up» button rolls on its wheels. Pressed, the button folds into a circle with a spinning ring, then opens again in green with a tick drawing itself and «Added»; the balance climbs digit by digit, «+$25.00» rises above it and the tag turns from Low balance to Active.
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>
<!--
"Top up credit button" 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 Top up button with amounts that snap into place</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>
<!-- the balance card of a travel eSIM app: pick an amount and the highlight snaps onto it, the button's figure rolls,
press Top up and it folds into a spinning ring, the balance counts up and the button opens again as Added -->
<section class="wallet" data-card aria-label="Balance">
<header class="wallet__head">
<p class="wallet__brand">
<span class="wallet__logo" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M4 15.5c3.2-5.4 12.8-5.4 16 0"></path><path d="M7.4 18.6c2.4-3 6.8-3 9.2 0"></path><path d="M12 5v6"></path></svg></span>
<span data-brand>Roamly</span>
</p>
<span class="tag tag--low" data-tag><span class="tag__in" data-tag-in>Low balance</span></span>
</header>
<div class="balance">
<p class="balance__label">eSIM balance <span class="balance__plan">· Europe 10 GB</span></p>
<div class="balance__row">
<p class="balance__value money" data-balance aria-live="polite"></p>
<span class="plus" data-plus aria-hidden="true">+$25.00</span>
</div>
</div>
<div class="amounts" role="radiogroup" aria-label="Top-up amount" data-amounts>
<span class="amounts__pill" data-pill aria-hidden="true"></span>
<button class="amount" type="button" role="radio" aria-checked="false" data-amount="10">$10</button>
<button class="amount" type="button" role="radio" aria-checked="true" data-amount="25">$25</button>
<button class="amount" type="button" role="radio" aria-checked="false" data-amount="50">$50</button>
<label class="amount amount--custom" data-custom>
<span class="amount__ph" data-custom-ph>Custom</span>
<span class="amount__cur" data-custom-cur aria-hidden="true">$</span>
<input class="amount__input" type="text" inputmode="numeric" maxlength="2" aria-label="Custom amount in dollars" data-custom-input>
</label>
</div>
<div class="cta" data-cta>
<button class="topup" type="button" data-topup>
<span class="topup__label" data-topup-label>Top up <span class="money" data-btn-amount></span></span>
<svg class="topup__ring" viewBox="0 0 24 24" aria-hidden="true" data-ring><circle cx="12" cy="12" r="8"></circle><path d="M12 4a8 8 0 0 1 8 8"></path></svg>
<span class="topup__done" data-done aria-hidden="true">
<svg viewBox="0 0 24 24"><path d="M6 12.4l4 4L18.2 8" data-tick></path></svg>
<span>Added</span>
</span>
</button>
</div>
<p class="meta" data-meta>
<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3.5" y="6" width="17" height="12" rx="2.5"></rect><path d="M3.5 10h17"></path></svg>
<span class="meta__text"><span data-meta-in>Visa ending 4242 · last top-up Oct 12</span></span>
</p>
<p class="sr" aria-live="polite" data-status></p>
</section>
<svg class="pointer" viewBox="0 0 24 24" aria-hidden="true" data-pointer><path d="M5 3l14 8.2-6.2 1.4 3.6 6.8-2.6 1.4-3.6-6.8L5 18.6z"></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.
30 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 “Top up credit button” from Animorio and fit it into my siteThe row of amounts has a single white pill under it, absolutely positioned. On each choice the chosen button is measured against the row and the pill goes to its x and its width on a back.out spring: so it slides from one amount to the next instead of switching on and off.
Every digit of the balance and the button is a strip of eleven cells, a blank one and then 0 to 9, inside a window one line tall and always the same width. To change number each strip moves by the yPercent of its new digit, from the last one on the right, with a small overshoot; a leading digit that isn’t needed sits on the blank cell with its window folded to zero width, and opens up when it arrives.
The button sits in a box of fixed size, so changing its width moves nothing. On click the label rises away, the width shrinks to the height (a circle) and an SVG ring spins inside; when the wait is over the width returns to full on back.out while the background turns green and the tick draws itself with its dash.
As the button opens again, a label with the added credit rises above the balance and the balance rolls to its new value. The tag and the line under the button change text by leaving upwards and coming back from below, inside a window with hidden overflow: the two texts never cross.
| Name | File | Default | What it changes |
|---|---|---|---|
BRAND | script.js | Roamly | The name of the invented eSIM app, at the top of the card. |
ACCENT | script.js | #16834e | The colour of the added credit, the active tag and the Added button. |
START | script.js | 8.4 | The starting balance, in dollars. |
PROCESS | script.js | 1.4 | The seconds the button spins in its ring before confirming. |
ROLL | script.js | 0.9 | The seconds the digits take to roll. |
SNAP | script.js | 1.7 | How much the white pill bounces when it snaps onto an amount. |
HOLD | script.js | 2.2 | The seconds the button stays on Added before going back. |
PAUSE | script.js | 1.2 | The seconds the autopilot waits between one gesture and the next. |
To top up the credit of an app: an eSIM, a wallet, call minutes, a transit pass, the credits of an artificial intelligence service. Anywhere you pick an amount and it pays to show the new balance right away.
The card takes the full width minus the margins and its spacing tightens with vmin; the balance is sized with clamp and the pill is recalculated on resize. The Custom field uses 16-pixel text, so Safari doesn’t zoom the page when it’s tapped, and opens the number pad.
No sliding pill, no rolling digits and no folding button: choices and balance change at once, «Added» and the return to «Top up» come with a fade; the drawn pointer stays hidden.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 7.8 KB; the libraries: GSAP 28 KB.
Tested on 28 October 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.