Skip to content
animorio
IT
All components

Hold to delete

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.4 KBGSAP 28 KBFreeDownload the zip

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.

The code

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>

Playground

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

Or ask your AI assistant for it

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 site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On a very light grey background, in the middle, the white row of a file, Q3 forecast.xlsx with its green icon and 2.4 MB · Edited 2 hours ago in grey, and below it a soft red button with a line drawn bin and the words Hold to delete. A fake pointer arrives, the button darkens slightly. Pressed, the button tightens a touch, its shadow shortens, the bin lifts its lid and the label becomes Keep holding: the solid red with white lettering advances from the left, like a bar filling up. The first time the pointer lets go halfway: the red slides back, the button widens again on a spring, the lid drops back with a small bounce and Hold a little longer appears underneath. The second time it holds all the way: in the last third the bin trembles more and more, then the button gives a small kick, the lid shuts with a knock and the bin squashes by a hair; the label becomes Deleted, the file row dims and says Moved to Trash. A moment later Undo takes the button’s place, white, with a thin line getting shorter: when time is up the row leaves to the left, the next file comes in (Brand guidelines.pdf, Offsite photos.zip) and the button turns red again.

How it works

Two identical layers

Inside 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.

Time is a number

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.

The trembling bin

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.

Undo

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.

Finger and keyboard

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.

Values to change

NameFileDefaultWhat it changes
HOLDscript.js1.2The seconds to hold to delete.
SQUEEZEscript.js0.965How much the button tightens while held (1 = not at all).
SHAKEscript.js5How many degrees the bin trembles towards the end.
UNDO_TIMEscript.js3.6The seconds in which you can still undo.
REDscript.js#e5484dThe red of the fill.
LABELscript.jsHold to deleteThe button’s label.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • Without pointer capture, on the phone a finger only has to slide a millimetre off the button and pointerup never arrives: the fill would carry on by itself.
  • A long press on iOS opens the system menu and selects the text: the button needs user-select none, a blocked contextmenu and touch-action none.
  • GSAP rotates the bin on the whole svg and the lid on its own group: the two transforms sit on different elements, otherwise one wipes out the other.
  • The three labels share one grid cell: the button takes the width of the longest and does not change size when the label changes.

Libraries

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.

Testing

Tested on 25 October 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

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.

All components