
The elastic button
Buttons, Hover, Text
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.
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>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
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 siteThe 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 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.
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 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.
| Name | File | Default | What it changes |
|---|---|---|---|
PRICE | script.js | 32 | The price of one bag, before the discount. |
DISCOUNT | script.js | 15 | The subscription discount, in percent. |
CURRENCY | script.js | $ | The currency sign in front of the price. |
DAYS | script.js | 30 | How often the refill ships, in days. |
SPRING | script.js | 1 | How springy everything is: 0.4 calm, 2 very bouncy. |
SPEED | script.js | 1 | The speed of everything: 2 twice as fast, 0.5 half. |
HOLD | script.js | 2.2 | How many seconds each state stays when the button plays by itself. |
AUTO | script.js | true | The button plays the gesture by itself until someone touches 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 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.
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.
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.
Tested on 1 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.