
The elastic button
Buttons, Hover, Text
The button that asks a restaurant to box up what is left on the plate. On tap the box’s flaps close on a spring, the box gives a small hop, the tape runs across and the label rolls to “Box on its way” while the button turns green. “Undo” opens beside it, with a line getting shorter: for a few seconds it can be taken back, then it goes away.
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>
<!--
"Doggy bag 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>Doggy bag button</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 button that asks the kitchen to box up what is left on the plate: the flaps close, the tape runs across,
and for a few seconds the request can still be undone -->
<div class="db" data-db data-state="idle">
<button class="db__main" type="button" data-main>
<span class="db__ico" aria-hidden="true">
<svg viewBox="0 0 24 24">
<path class="db__body" d="M5 10.500h14v8a1.500 1.500 0 0 1-1.500 1.500h-11A1.500 1.500 0 0 1 5 18.500Z"></path>
<line class="db__flap" data-flap="l" x1="5" y1="10.500" x2="12" y2="10.500"></line>
<line class="db__flap" data-flap="r" x1="19" y1="10.500" x2="12" y2="10.500"></line>
<path class="db__tape" data-tape pathLength="1" d="M12 10.500v4.200"></path>
<path class="db__tick" data-tick pathLength="1" d="m8.800 15.300 2.300 2.300 4.300-4.700"></path>
</svg>
</span>
<span class="db__label"><span data-label>Box up the rest</span></span>
</button>
<button class="db__undo" type="button" data-undo tabindex="-1" aria-hidden="true"><span>Undo</span><i aria-hidden="true"><b data-bar></b></i></button>
<span class="db__live" aria-live="polite" data-live></span>
</div>
<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.
11 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 “Doggy bag button” from Animorio and fit it into my siteIdle, packing, sent (can be undone) and done. The state is written in an attribute of the pill: CSS takes the colour from it, the script the labels and which of the two buttons can be tapped.
They are two SVG lines turning around their hinges. The angle is a single number, animated by GSAP on an elastic spring and written in the transform attribute with the centre of rotation in viewBox coordinates.
A line shortening on a linear tween UNDO seconds long: when it ends it closes “Undo” and moves to the done state. Undoing stops the tween and goes back to idle.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #2f8f63 | The colour of the button once the request has gone. |
UNDO | script.js | 3.6 | For how many seconds it can still be undone. |
CLOSE | script.js | 0.7 | How long the box’s flaps take to close. |
In the digital menu or at-table app of a restaurant, a trattoria or a pizzeria, next to “Call the waiter” and the bill; and wherever a request goes out at once but can still be withdrawn for a few seconds.
The same button, 56 pixels tall: with “Undo” open it is about 270 pixels wide and fits a phone screen; both buttons are 48 pixels tall and easy to hit with a thumb.
No springs and no hops: the flaps are closed at once, the tick appears, the label changes and “Undo” shows up at full width. Only the time line still shortens, because it says how long is left.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 4.8 KB; the libraries: GSAP 28 KB.
Tested on 25 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.