
The elastic button
Buttons, Hover, Text
The auto-renew switch of a subscription, on white: below it a bar shows the current period with the part already gone and, after it, the one to come. Turn it off and the next period withdraws, the bar stretches to its end and the words go from “Renews on 14 Dec” to the count of the days left, in amber.
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>
<!--
"Auto-renew toggle" 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>Auto-renew toggle</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 auto-renew switch of a subscription: the bar is the period you are in; turned on, the next period
slides in after it, turned off the period stretches to its end and the date says when it stops -->
<section class="ar" data-ar>
<div class="ar__head">
<div>
<h1 id="ar-title">Auto-renew</h1>
<p class="ar__plan">Studio plan, €9.00 a month</p>
</div>
<button class="ar__switch" type="button" role="switch" aria-checked="true" aria-labelledby="ar-title" data-switch><span class="ar__knob" data-knob></span></button>
</div>
<div class="ar__cycle" aria-hidden="true">
<span class="ar__now" data-nowbar><i data-spent></i></span>
<span class="ar__next" data-nextbar></span>
<span class="ar__today" data-today></span>
</div>
<p class="ar__dates" aria-hidden="true"><span>14 Nov</span><span data-edge>14 Dec</span><span data-far>14 Jan</span></p>
<p class="ar__state"><span data-state>Renews on 14 Dec</span></p>
<span class="ar__say" data-say aria-live="polite"></span>
</section>
<svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.
17 values to change
Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI
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 “Auto-renew toggle” from Animorio and fit it into my siteA single number, 0 to 1, says how much room the next period takes: the width of the two pieces, today’s notch and the position of the dates all come from it.
The click takes that number to 1 on a spring or to 0 with a soft exit; the knob slides 20 pixels and stretches for a moment.
A class on the card changes a CSS variable: the gone part of the bar and the words go from green to amber with a transition.
They roll out and come back with the new text; the days left are a value to change.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #13a36c | The colour of auto-renew when on. |
OFF | script.js | #d98512 | The colour used when the subscription is about to end. |
SPENT | script.js | 0.3 | How much of the period has already gone: 0 to 1. |
DAYS | script.js | 21 | How many days are left until the period ends. |
SPRING | script.js | 1 | How much the knob and the bar bounce: 0.3 = a little, 2 = a lot. |
LOOP | script.js | true | Left alone, the demo’s pointer turns auto-renew off and then back on. |
On the subscription or billing page of an app, a service, a shop with recurring deliveries, a gym. Wherever someone turning renewal off should see at once until when they can still use what they paid for.
The same card, 292 pixels wide at most: the switch is 30 pixels tall and 50 wide, the bar takes the full width and the three dates fit on one line.
The knob and the bar go straight to the new state, the words change without rolling; the colours change with their transition. The demo does not move by itself.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 4.4 KB; the libraries: GSAP 28 KB.
Tested on 23 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.
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.