Skip to content
animorio
IT
All components

Subscribe and save button

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

The buy button of a coffee roaster that sells beans by subscription, one pill of smoked glass on black, premium like a Dribbble shot. On the left a round glass key is the refill switch: turned on, a ring of amber light runs around it, the two arrows turn once and settle, a small glass chip rises over the pill (Every 30 days, Save 15%), an amber haze wakes under the glass and the price drops: the old one goes small and is struck through, the new one rolls its figures like an odometer. The rest of the pill adds to the bag: it gives under the finger, a beam of light crosses the glass, an amber light runs once around the edge and a check draws itself where the price was.

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>
<!--
  "Subscribe and save 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 Subscribe and save button with the price that drops</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">
    <!-- the buy button of a coffee subscription shop, in smoked glass on black. The round glass key on the left is the
         refill switch: on, a ring of amber light runs around it, the arrows turn once, a chip rises over the pill and
         the price drops by 15 percent with rolling figures while the old one is struck through. The rest of the pill
         adds to the bag: a beam crosses the glass, the edge lights up all the way round and a check takes the price's place -->
    <div class="sub" data-sub>
      <span class="sub__tag" data-tag aria-hidden="true">
        <svg class="sub__tag-icon" viewBox="0 0 16 16"><path d="M3.2 6.6A5 5 0 0 1 12.4 5M12.8 9.4A5 5 0 0 1 3.6 11"/><path d="M12.6 2.4v2.8H9.8M3.4 13.6v-2.8h2.8"/></svg>
        <span>Every 30 days</span>
        <span class="sub__tag-save" data-save>Save 15%</span>
      </span>

      <div class="sub__pill" data-pill>
        <span class="sub__grain" aria-hidden="true"></span>
        <span class="sub__glow" data-glow aria-hidden="true"></span>
        <span class="sub__edge" aria-hidden="true"></span>
        <span class="sub__run" data-run aria-hidden="true"></span>
        <span class="sub__beam" data-beam aria-hidden="true"></span>

        <button class="sub__toggle" type="button" aria-pressed="false" aria-label="Subscribe and save" data-toggle>
          <span class="sub__key" data-key>
            <svg class="sub__ring" viewBox="0 0 44 44" aria-hidden="true">
              <circle class="sub__ring-track" cx="22" cy="22" r="20.5"/>
              <circle class="sub__ring-fill" data-ring cx="22" cy="22" r="20.5" pathLength="1"/>
            </svg>
            <svg class="sub__loop" data-loop viewBox="0 0 16 16" aria-hidden="true">
              <path d="M3.2 6.6A5 5 0 0 1 12.4 5M12.8 9.4A5 5 0 0 1 3.6 11"/>
              <path d="M12.6 2.4v2.8H9.8M3.4 13.6v-2.8h2.8"/>
            </svg>
          </span>
        </button>

        <span class="sub__rule" aria-hidden="true"></span>

        <button class="sub__cta" type="button" data-cta>
          <span class="sub__label">
            <span class="sub__window"><span class="sub__words" data-words>Add to bag</span></span>
            <span class="sub__small" data-small>One-time purchase</span>
          </span>
          <span class="sub__price" data-price>
            <span class="sub__was" data-was><span data-was-text>$32.00</span><i class="sub__strike" data-strike></i></span>
            <span class="sub__now" data-now aria-hidden="true"></span>
            <span class="sub__done" data-done aria-hidden="true">
              <svg class="sub__check" viewBox="0 0 20 20"><path data-check pathLength="1" d="M5.4 10.4l3.1 3.1 6.2-6.8"/></svg>
            </span>
          </span>
        </button>
      </div>
    </div>
    <p class="sr" aria-live="polite" data-live></p>
  </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.

21 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 “Subscribe and save 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 black, alone in the middle, there is a pill of smoked glass sixty pixels tall: a graphite body with a highlight on top, a very fine grain and a one-pixel edge that catches the light. Inside, on the left, a round glass key with two arrows chasing each other; a thin rule; then «Add to bag», «One-time purchase» underneath and the price on the right, $32.00. A soft light follows the pointer inside the glass and along the edge, on a spring. Tap the round key and it gives and comes back on an elastic, an amber ring draws itself around it, the arrows make a full turn and stop a hair past it, the key warms with amber light and a haze lights up under the pill. Over the pill a small glass chip rises on a spring: the arrows, «Every 30 days» and «Save 15%» in amber. The old price rises small and a line strikes it from the left; the new one, $27.20, rolls each figure like an odometer, one after the other; «Add to bag» leaves upwards and «Subscribe» comes in, with «Ships every 30 days» underneath. Press the rest of the pill and the whole pill gives and comes back on an elastic, a beam of light crosses it from left to right, an amber light runs around the edge, the price rises away blurring and an amber check draws itself in its place: «Subscribed», «First box ships tomorrow». Another tap goes back. Until someone touches it, it does everything by itself, with the light going over to press the keys.

How it works

The layered glass

The pill is a graphite body with two gradients and three shadows (highlight on top, a dark thread at the bottom, a long shadow), and over it thin layers that ignore the pointer: the grain of an feTurbulence in an inline SVG, the light under the pointer (a radial-gradient at the --mx and --my variables), and the one-pixel edge made with a mask that carves out the content (mask-composite: exclude) and gets brighter where the light is.

The light on a spring

The pointer gives a target in fractions of the pill (so resizing does not move it); a loop on GSAP's ticker chases it with a real spring, velocity plus stiffness times the time step and exponential damping, and writes --mx, --my and the intensity --gi. When the light is still the loop removes itself.

The rolling price

Each figure is a window one line tall with the column from 0 to 9 inside; GSAP takes the column to a yPercent of minus ten times the figure, with a back.out and a small delay for each place, like an odometer. If the new price has a different number of characters, the column is rebuilt with a fade.

The run of light on the edge

The amber run is a conic-gradient with a single lit slice, masked like the edge; GSAP tweens the --a variable, the angle the conic starts from, from 200 to 560 degrees. The beam is a slanted gradient that travels with the --bx variable to the measured width of the pill.

Values to change

NameFileDefaultWhat it changes
PRICEscript.js32The price of one bag, before the discount.
DISCOUNTscript.js15The subscription discount, in percent.
CURRENCYscript.js$The currency sign in front of the price.
DAYSscript.js30How often the refill ships, in days.
SPRINGscript.js1How springy everything is: 0.4 calm, 2 very bouncy.
SPEEDscript.js1The speed of everything: 2 twice as fast, 0.5 half.
HOLDscript.js2.2How many seconds each state stays when the button plays by itself.
AUTOscript.jstrueThe button plays the gesture by itself until someone touches it.

Try them in the Playground

When to use it

On the page of a product people buy again (coffee, tea, skincare, pet food, supplements) in an online shop that offers a discounted subscription: one button says at once how much you save, how often it ships and puts it in the bag.

On phones

On the phone the pill is as wide as the screen minus the margins (380 pixels at most) and the inner padding narrows with clamp; the light does not follow a sliding finger but goes where it lands, everything else is the same.

With reduced motion

Nothing moves: the amber ring, the chip and the struck price fade in, the new price fades in place of the old one instead of rolling, the words swap with a fade, no beam or run of light, no bounces; the light stays still.

Pitfalls

  • The glowing edge with the mask: Safari wants -webkit-mask-composite: xor, the others mask-composite: exclude; without both the edge becomes a filled disc over the pill.
  • The light's variables sat on the light layer, and the edge (a sibling, not a child) could not see them: they go on the pill, so both layers inherit them.
  • The discount changes the length of the price when PRICE goes from two to three figures: the columns cannot roll, they are rebuilt with a fade.
  • Turning off the subscription after pressing the button left the check over the price: the round key first takes the button back to rest, then changes the price.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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