
The elastic button
Buttons, Hover, Text
The Compare button on the product card of a made-up bike shop, premium on black: on click the bike's thumbnail leaves the pill and flies on an arc into the compare bar rising from below, the button turns into “Added · 2 of 3” with a drawn check and the bar shows Compare now; a second click flies it back, and with the bar full the button dims into Compare list full.
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>
<!--
"Compare 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 Compare button with the thumbnail that flies into the bar</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 Compare button of a made-up bike shop's product card: pressed, the small thumbnail of the bike leaves the
pill and flies on an arc into the compare bar that rises from below; a second press takes it back -->
<svg width="0" height="0" style="position:absolute" aria-hidden="true">
<symbol id="bike" viewBox="0 0 32 32">
<circle cx="9" cy="20" r="5.6"></circle>
<circle cx="23" cy="20" r="5.6"></circle>
<path d="M9 20 13.6 12.4h8.2L23 20M13.6 12.4 16.4 20h-7.4M16.4 20l5.4-7.6M12.4 10h3.2M20.2 9.6h2.8l-1.2 2.8"></path>
</symbol>
</svg>
<div class="wrap" data-wrap>
<div class="pill" data-pill>
<span class="pill__floor" aria-hidden="true"></span>
<div class="pill__clip">
<span class="pill__grain" aria-hidden="true"></span>
<span class="pill__sheen" aria-hidden="true"></span>
<button class="cmp" type="button" data-cmp aria-pressed="false" aria-label="Add Velomar Arc 2 to compare">
<span class="socket" data-socket aria-hidden="true">
<span class="tile tile--arc" data-thumb><svg><use href="#bike"></use></svg><span class="tile__gloss"></span></span>
</span>
<span class="label"><span class="label__in" data-label>Compare</span></span>
<span class="ic" aria-hidden="true">
<svg viewBox="0 0 24 24">
<g class="ic__cmp" data-iccmp><rect x="3.6" y="5.2" width="6.8" height="13.6" rx="1.8"></rect><rect x="13.6" y="5.2" width="6.8" height="13.6" rx="1.8"></rect><path d="M6 9.2h2M16 9.2h2M6 12h2M16 12h2"></path></g>
<circle class="ic__ring" data-icring cx="12" cy="12" r="8.6"></circle>
<path class="ic__check" data-iccheck d="M7.8 12.4 10.8 15.3 16.4 9.2"></path>
<path class="ic__full" data-icfull d="M6.2 17.8 17.8 6.2"></path>
</svg>
</span>
</button>
</div>
<span class="pill__edge" aria-hidden="true"></span>
</div>
<div class="bar" data-bar role="region" aria-label="Compare list">
<span class="bar__edge" aria-hidden="true"></span>
<div class="slots">
<button class="slot" type="button" data-slot="0" aria-label="Empty slot, add a bike"><span class="slot__plus" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M12 7v10M7 12h10"></path></svg></span><span class="slot__ring" aria-hidden="true"></span></button>
<button class="slot" type="button" data-slot="1" aria-label="Empty slot, add a bike"><span class="slot__plus" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M12 7v10M7 12h10"></path></svg></span><span class="slot__ring" aria-hidden="true"></span></button>
<button class="slot" type="button" data-slot="2" aria-label="Empty slot, add a bike"><span class="slot__plus" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M12 7v10M7 12h10"></path></svg></span><span class="slot__ring" aria-hidden="true"></span></button>
</div>
<div class="cta">
<span class="cta__hint" data-hint>Add 1 more</span>
<a class="go" href="#compare" data-go>
<span class="go__word">Compare now</span>
<svg class="go__arrow" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h13M13 7l5 5-5 5"></path></svg>
</a>
</div>
</div>
<p class="sr" data-live aria-live="polite"></p>
</div>
<svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></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.
20 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 “Compare button” from Animorio and fit it into my siteThe flying thumbnail is a copy of the tile fixed to the window. A single tween moves a variable p from 0 to 1, and every frame reads the rectangles of the recess and the slot again: x and y follow an in-out ease, the height loses ARC_HEIGHT times sin(πp), while size, corner radius and rotation move from one shape to the other. So the flight lands right even while the bar is still rising or the window changes size.
The pill’s width is measured on a hidden clone of the label in the same typeface: GSAP moves it with back.out while the old words leave upwards and the new ones come in from below. When only the slot count changes, only the number rolls, in tabular figures.
The icon has four SVG parts: the two columns, the ring, the check and the full state stroke. Ring, check and stroke draw themselves with stroke-dashoffset, the columns turn away and shrink.
An array of three slots says who is in; from it come the button state (Compare, Added, Compare list full), the words in the bar (Add 1 more or Compare now) and the bar itself, which rises when our bike is in or there are at least two.
| Name | File | Default | What it changes |
|---|---|---|---|
LABEL | script.js | Compare | The label of the button at rest. |
ADDED | script.js | Added | The word of the added state, before the slot count. |
FULL_LABEL | script.js | Compare list full | The label of the dimmed button when the bar is full. |
ACCENT | script.js | #ff8a4c | The colour of the check, the slot glow and Compare now. |
FLIGHT | script.js | 0.75 | How many seconds the thumbnail’s flight lasts. |
ARC_HEIGHT | script.js | 64 | How high the flight’s arc rises, in pixels. |
SPRING | script.js | 0.6 | How long the spring that changes the pill’s width lasts, in seconds. |
On the product cards of a bike, electronics, phone or appliance shop, in an e-commerce results grid, in plan listings: wherever people pick two or three things to put side by side.
The bar narrows to the screen width minus thirty-two pixels, under 360 the slots go down to 40 pixels and Compare now gets narrower; a finger presses like the mouse and taps bikes in the bar to take them out. Without hover the edge light stays still in the middle.
No flight or springs: the thumbnail fades out of the recess and into the slot, the bar fades in and out in place, the words cross-fade and the check arrives already drawn.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 9.4 KB; the libraries: GSAP 28 KB.
Tested on 13 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.