Skip to content
animorio
IT
All components

Top up credit button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.8 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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>

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.

30 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 “Top up credit button” 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 the palest grey sits the balance card of Roamly, an invented eSIM app for travellers: the mark, the amber «Low balance» tag, the big balance, $8.40, with the Europe 10 GB plan, the row of amounts ($10, $25, $50, Custom), the black «Top up $25» button and underneath the payment card with the last top-up. Picking an amount, a white pill with its shadow snaps under it with a small bounce, the chosen amount squashes slightly and springs back, and the figure on the button rolls on its wheels to the new value. Custom opens into a tiny field to type any amount from 5 to 99 dollars. Pressed, «Top up» squashes, its label rises away and the button shrinks into a circle with a white ring spinning inside; then it widens again in green with a bounce, the tick draws itself and «Added» appears. Meanwhile «+$25.00» rises above the balance, the balance climbs rolling digit by digit from right to left to $33.40 (the tens digit, which wasn’t there before, opens up in its place), the tag rolls to a green «Active» and the line below to «topped up just now». After a moment the button turns black again with its «Top up». A drawn pointer tries $10 and $50, goes back to $25 and presses; you can also use it by hand.

How it works

The pill that snaps

The 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.

Digits on wheels

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 folding into a ring

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.

The balance climbing and the text rolling

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.

Values to change

NameFileDefaultWhat it changes
BRANDscript.jsRoamlyThe name of the invented eSIM app, at the top of the card.
ACCENTscript.js#16834eThe colour of the added credit, the active tag and the Added button.
STARTscript.js8.4The starting balance, in dollars.
PROCESSscript.js1.4The seconds the button spins in its ring before confirming.
ROLLscript.js0.9The seconds the digits take to roll.
SNAPscript.js1.7How much the white pill bounces when it snaps onto an amount.
HOLDscript.js2.2The seconds the button stays on Added before going back.
PAUSEscript.js1.2The seconds the autopilot waits between one gesture and the next.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • A balance going from $8.40 to $33.40 changes its number of digits: with wheels built on the old number the tens digit would have no place. The wheels are always the same, and the one not needed sits on the blank cell with its window at zero width.
  • In Mona Sans tabular figures draw a slashed zero: the digits sit in fixed-width windows instead of using tabular-nums.
  • A button shrinking into a circle would change the height of the card if it were in the normal flow: it sits in a box of fixed size and only its width is animated.

Libraries

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.

Testing

Tested on 28 October 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