
The elastic button
Buttons, Hover, Text
A soft red Hold to delete button under a file row, on very light grey: one gesture, press and hold. The solid red fills from the left in just over a second, the button tightens a touch and the bin lifts its lid and trembles towards the end; let go early and it springs back, reach the end and the lid shuts, the file goes to the trash and Undo stays for a few seconds.
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>
<!--
"Hold to delete" 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 hold to delete 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">
<!-- one gesture: press and hold. A file row and a soft red button: holding fills the button from the left,
letting go early springs it back, finishing closes the bin's lid and leaves a few seconds to undo -->
<section class="pezzo" data-pezzo aria-label="Delete a file">
<div class="file" data-file>
<span class="file__icon" aria-hidden="true">
<svg viewBox="0 0 24 24"><path d="M6.5 3.5h7.2l4.8 4.8v11.2a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1v-15a1 1 0 0 1 1-1Z"></path><path d="M13.5 3.7v4.8h4.8"></path></svg>
</span>
<span class="file__text">
<span class="file__name"><span data-name>Q3 forecast.xlsx</span><span class="file__strike" data-strike></span></span>
<span class="file__metas"><span class="file__meta" data-meta>2.4 MB · Edited 2 hours ago</span><span class="file__gone" data-gone>Moved to Trash · kept for 30 days</span></span>
</span>
</div>
<button class="hold" type="button" data-hold aria-label="Hold to delete Q3 forecast.xlsx">
<span class="hold__body" data-body>
<span class="hold__layer hold__layer--base">
<svg class="bin" viewBox="0 0 24 24" aria-hidden="true">
<g class="bin__lid" data-lid><path d="M4.5 6.6h15"></path><path d="M9.6 6.4V5a1.2 1.2 0 0 1 1.2-1.2h2.4A1.2 1.2 0 0 1 14.4 5v1.4"></path></g>
<g class="bin__can" data-can><path d="M6.4 6.8l.9 12a1.4 1.4 0 0 0 1.4 1.3h6.6a1.4 1.4 0 0 0 1.4-1.3l.9-12"></path><path d="M10.2 10.4v6M13.8 10.4v6"></path></g>
</svg>
<span class="hold__labels"><span class="lab" data-lab="rest">Hold to delete</span><span class="lab" data-lab="busy">Keep holding</span><span class="lab" data-lab="done">Deleted</span></span>
</span>
<span class="hold__layer hold__layer--top" data-top aria-hidden="true">
<svg class="bin" viewBox="0 0 24 24">
<g class="bin__lid" data-lid><path d="M4.5 6.6h15"></path><path d="M9.6 6.4V5a1.2 1.2 0 0 1 1.2-1.2h2.4A1.2 1.2 0 0 1 14.4 5v1.4"></path></g>
<g class="bin__can" data-can><path d="M6.4 6.8l.9 12a1.4 1.4 0 0 0 1.4 1.3h6.6a1.4 1.4 0 0 0 1.4-1.3l.9-12"></path><path d="M10.2 10.4v6M13.8 10.4v6"></path></g>
</svg>
<span class="hold__labels"><span class="lab" data-lab="rest">Hold to delete</span><span class="lab" data-lab="busy">Keep holding</span><span class="lab" data-lab="done">Deleted</span></span>
</span>
</span>
</button>
<button class="undo" type="button" data-undo tabindex="-1" aria-hidden="true">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 7.5 5 11.5l4 4"></path><path d="M5.4 11.5h8.6a4.6 4.6 0 0 1 0 9.2h-2"></path></svg>
<span>Undo</span>
<span class="undo__bar" data-bar></span>
</button>
<p class="hint" data-hint>Press and hold for a moment</p>
</section>
<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.
27 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 “Hold to delete” from Animorio and fit it into my siteInside the button there are two copies of the same row, bin and label: below red on pink, above white on solid red. The top layer is cut by an inset clip-path that opens from the left: the fill does not cover the label, it changes its colour exactly where it passes.
The fill is a single number from 0 to 1 that GSAP moves forward over HOLD seconds, with no curve, for as long as you hold. Let go and the tween stops and another takes it back to 0 with power3.out, from wherever it had got to: going back is always quicker than going forward.
In the last 38% of the run the bin rotates on a fast sine of the ticker’s time, with an amplitude that grows up to SHAKE degrees: you can tell it is nearly done without reading anything. The lid is a separate group turning on its hinge, on the right: it lifts on press, drops back with back.out and shuts with a small bounce.
At the end the button gives way to Undo in the same grid cell, with a line that shortens over UNDO_TIME seconds. If it runs out, the file row leaves to the left and the next one comes in; press Undo and the row lights up again and the button turns red.
The button uses pointerdown and pointerup with pointer capture, so a finger sliding off does not leave the press half done, and touch-action none so the page does not scroll; holding Space or Enter works too. At the first touch the autopilot stops.
| Name | File | Default | What it changes |
|---|---|---|---|
HOLD | script.js | 1.2 | The seconds to hold to delete. |
SQUEEZE | script.js | 0.965 | How much the button tightens while held (1 = not at all). |
SHAKE | script.js | 5 | How many degrees the bin trembles towards the end. |
UNDO_TIME | script.js | 3.6 | The seconds in which you can still undo. |
RED | script.js | #e5484d | The red of the fill. |
LABEL | script.js | Hold to delete | The button’s label. |
For actions you should not trigger by mistake, without opening a confirmation dialog: deleting a file, a project, an account, emptying the trash, cancelling a subscription, in an app, a dashboard or a file manager.
The same button at the same size: a finger holds like the mouse, the page does not scroll while holding (touch-action none) and the long press menu does not open. The file row narrows to the box’s width and trims the name with an ellipsis.
No squeezing, trembling or moving lids: the solid red fades in as you hold, the labels change with a fade and the file row dims without moving.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 6.4 KB; the libraries: GSAP 28 KB.
Tested on 25 October 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.