Skip to content
animorio
IT
All components

Store credit button

Buttons, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 8.7 KBGSAP 28 KBFreeDownload the zip

The Apply store credit button in the cart of a homeware shop, a graphite pill with grain, an edge that catches the light and a €24.00 balance sunk into a notch, like a Dribbble shot. Under it sits the order total, €86.00. Pressed, a mint ring runs round the credit tag while it checks the balance; then the balance lifts out of the pill as a mint token, drops in an arc onto the total and becomes its discount, the total rolls down on its wheels to €62.00, the balance left rolls to €0.00 and emerald spreads over the pill from where the credit was. Another tap takes the credit back: the token flies up into the pill and the total rolls up again.

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>
<!--
  "Store 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 Apply store credit button with the balance that drops into the total</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">
    <!-- one gesture: spend the credit. Pressed, a ring draws round the credit tag while it checks; then the balance
         lifts out of the pill as a small mint token, falls in an arc onto the order total and becomes its discount,
         the total rolls down on its wheels and the emerald spreads over the pill from where the balance was.
         Another press takes the credit back: the token flies up into the pill and the total rolls up again -->
    <div class="frame" data-wrap>
      <button class="s" type="button" data-btn data-autoclic aria-pressed="false" aria-describedby="s-note">
        <span class="s__shell" data-shell aria-hidden="true">
          <span class="s__skin"></span>
          <span class="s__fill" data-fill></span>
          <span class="s__glow" data-glow></span>
          <span class="s__sheen" data-sheen></span>
          <span class="s__grain"></span>
        </span>

        <span class="s__icon" aria-hidden="true">
          <svg class="s__ring" viewBox="0 0 36 36"><circle class="ring__track" cx="18" cy="18" r="16.5"></circle><circle class="ring__run" data-ring cx="18" cy="18" r="16.5"></circle></svg>
          <span class="s__tag" data-tag>
            <svg viewBox="0 0 24 24"><path class="tag__body" d="M4.5 8.2c0-1.1.9-2 2-2h7.6c.5 0 1 .2 1.4.6l4.2 4.2c.8.8.8 2 0 2.8l-4.2 4.2c-.4.4-.9.6-1.4.6H6.5c-1.1 0-2-.9-2-2Z"></path><circle class="tag__hole" cx="15.4" cy="12" r="1.25"></circle><path class="tag__line" d="M7.6 10.2h4.2M7.6 13.8h2.6"></path></svg>
          </span>
          <span class="s__check" data-check>
            <svg viewBox="0 0 24 24"><path data-tick d="M6.6 12.4l3.6 3.5 7.2-7.6"></path></svg>
          </span>
        </span>

        <span class="s__labels" data-labels>
          <span class="s__label" data-l="idle">Apply store credit</span>
          <span class="s__label" data-l="wait">Checking balance</span>
          <span class="s__label" data-l="done">Credit applied</span>
        </span>

        <span class="s__chip" data-chip aria-hidden="true">
          <span class="chip__skin" data-chipskin></span>
          <span class="odo" data-odo="balance"></span>
          <span class="chip__left" data-left>&nbsp;left</span>
        </span>
      </button>

      <p class="note" id="s-note" data-note aria-live="polite">
        <span class="note__k">Order total</span>
        <span class="note__total odo" data-odo="total"></span>
        <span class="note__badge" data-badge>
          <span class="badge__skin"></span>
          <span class="badge__txt">&minus;&euro;<span data-credit-txt>24.00</span></span>
        </span>
      </p>

      <span class="token" data-token aria-hidden="true">
        <span class="token__skin"></span>
        <span class="token__txt">&minus;&euro;<span data-token-txt>24.00</span></span>
      </span>

      <span class="sr" data-sr></span>
    </div>
  </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.

22 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 “Store 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 a white ground sits the graphite Apply store credit pill: on the left the credit tag drawn in line in a small round window, on the right the €24.00 balance sunk into a darker notch, and under it the grey Order total line with the €86.00 total. On hover a cool light follows the pointer, the pill swells by a few pixels with a bounce, the label widens on the font’s wdth axis and the tag tilts; pressed, the pill squashes slightly. On the tap the label rolls to Checking balance, a mint ring draws round the tag and the tag rocks. Then the balance lifts out of the notch as a small mint −€24.00 token, rises a little and drops in an arc, leaning as it flies, to the side of the total, where it squashes and becomes its discount; the total dips by two pixels and its digits roll from the right to €62.00. Meanwhile in the notch the balance rolls to €0.00 left, the tag turns into a tick, emerald spreads over the pill in a circle that starts at the notch, the pill swells a hair and a light crosses it; the label says Credit applied. Another tap takes the credit back: the token flies up into the pill on its arc, the emerald draws back and the total rolls to €86.00 again.

How it works

The digits on their wheels

Every digit is a column holding the ten digits and a blank, eleven rows tall, which GSAP moves with yPercent one eleventh at a time: the columns turn from the right, cents first, with a back.out that passes the digit by a hair and returns. The blank hides a leading zero while the column narrows to nothing, so €24.00 becomes €0.00 with no gap.

The token that flies on an arc

The token lives outside the button, in the component’s frame. When it flies the script measures the middle of the notch and the discount’s final place beside the total (opening the badge to its true size for a moment), then a 0 to 1 tween carries it along a quadratic Bézier curve with its control point above both ends; the lean follows the sine of the path, so it leaves tilted and lands straight.

The emerald that starts from the credit

The emerald layer has a circle clip-path in pixels centred on the notch: the radius runs from zero to the distance of the farthest corner, worked out again on every resize. Both states use the same circle form, so GSAP blends them without jumps.

The elastic pill

Like the site’s pill: on hover the shell holding the layers grows six pixels each side with an elastic.out and the label goes from wdth 100 to 114, both widths measured first, so nothing around it jumps. Each label’s width is measured again after document.fonts.ready.

Values to change

NameFileDefaultWhat it changes
CREDITscript.js24The store credit to use, in euros: the balance in the pill and the discount on the total.
TOTALscript.js86The order total before the credit, in euros.
WAITscript.js1.0The seconds the ring runs round the tag.
FLIGHTscript.js0.8The seconds the token flies to the total.
ARCscript.js34How high the token’s arc rises before it drops, in pixels.
BOUNCEscript.js1.5How much the pill, the digits and the token bounce.
MIN_HOLDscript.js2.4The least seconds the autopilot leaves the applied credit in view.
--smeraldostyle.css#16402fThe emerald that fills the pill once the credit is applied.
--mentastyle.css#b8ebcdThe mint of the ring, the tick and the token.

Try them in the Playground

When to use it

In the cart or checkout of an online shop, to spend the credit left from a return or a refund: the shopper sees the money move from the balance to the total and knows at once what they pay.

On phones

The pill drops to 56 pixels, the label by a point and the notch to 38; the finger taps like the mouse. Without hover the pill does not swell and the light stays off; the rest is the same.

With reduced motion

No flight and no rolling: the ring appears already closed, the labels and digits change with a fade, the emerald and the discount beside the total fade in where they belong; on the way back they fade out.

Pitfalls

  • The token’s final place must be measured with the badge already at its true width: measured at zero width, the token landed in the middle of the total. The script opens it for an instant, reads the position and closes it before it shows.
  • The preview’s autopilot clicks every 2.8 seconds and closed the credit just applied: untrusted clicks (isTrusted false) wait MIN_HOLD seconds from the applied state, people’s clicks do not.
  • The emerald circle in percent did not follow the notch when the pill swells: it goes in pixels, measured every time and on every resize.
  • The blank digit column kept a digit’s width and left a gap before €0.00: the column narrows to zero along with the roll.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 16 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