Skip to content
animorio
IT
All components

Empty trash button

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

The button that empties the trash of a files app, to be held down: while a red wash crosses it the bin’s lid lifts, the contents sink and the files and megabytes count down to zero. Let go early and everything goes back. At the end the lid drops, the tick appears and the button says how much space came back.

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>
<!--
  "Empty trash 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>Empty trash 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 empties the trash: it has to be held; while it fills the lid lifts, the bin drains
         and the items count down, then it says how much space came back -->
    <div class="et" data-et>
      <button class="et__btn" type="button" data-btn aria-describedby="et-hint">
        <span class="et__fill" data-fill aria-hidden="true"></span>
        <span class="et__icon" aria-hidden="true">
          <svg class="et__can" data-can viewBox="0 0 28 28">
            <rect class="et__level" data-level x="9.600" y="12.400" width="8.800" height="9.600" rx="1.200"></rect>
            <path d="M7.800 11.200l.9 10.500a2 2 0 0 0 2 1.800h6.600a2 2 0 0 0 2-1.800l.9-10.500"></path>
            <g data-lid><path d="M6 8.400h16"></path><path d="M11 8.400V6.700a1.300 1.300 0 0 1 1.300-1.300h3.400A1.300 1.300 0 0 1 17 6.700v1.700"></path></g>
          </svg>
          <svg class="et__tick" data-tick viewBox="0 0 28 28"><path d="M7.500 14.600l4.300 4.300 8.700-9.500"></path></svg>
        </span>
        <span class="et__text">
          <span class="et__label"><span data-label>Empty trash</span></span>
          <span class="et__sub"><span data-sub></span></span>
        </span>
      </button>
      <p class="et__hint" id="et-hint"><span data-hint>Hold to empty</span></p>
      <span class="et__say" data-say aria-live="polite"></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>

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.

13 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Empty trash button” 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 white, a pale grey pill: on the left a white tile with a line-drawn bin, full of red, then “Empty trash” and under it “12 items, 348 MB”; lower down, small, “Hold to empty”. Hold it down and the button gives a little, the bin’s lid lifts at a tilt, the bin barely trembles and a red wash advances from the left with a brighter edge; meanwhile the red inside the bin sinks and the line below counts: 9 items, 5 items, 135 MB. Let go too early and the wash goes back, the lid drops with a bounce and “Hold to empty” gives a small jolt. At the end the lid closes, the bin makes way for a red tick drawing itself, and the words roll into “Trash emptied” and “348 MB freed”. After a moment, in the demo, the bin fills up again.

How it works

A number for the press

Holding down, a tween takes a number from 0 to 1 in HOLD seconds, linearly; on letting go another tween takes it back to zero.

Everything reads that number

A single function draws the wash (scaleX), the level in the bin (scaleY from the bottom) and the line of files and megabytes, all from the same value.

The lid

It has a number of its own: it opens on an elastic as soon as you press and drops with a bounce, turning about its left corner.

The end

When the number reaches 1 the wash fades, the bin shrinks and the tick draws itself with the dashoffset while the two lines of text roll.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#f0453aThe colour of the wash while holding, of the bin’s contents and of the tick.
HOLDscript.js1.2For how many seconds the button must be held.
ITEMSscript.js12How many files are in the trash.
SIZEscript.js348How much space they take, in megabytes (from 1024 up it becomes GB).
SPRINGscript.js1How much the lid and the button bounce: 0.3 = a little, 2 = a lot.
LOOPscript.jstrueLeft alone, the demo’s pointer lets go too early, then holds all the way.

Try them in the Playground

When to use it

In the trash of a files, mail, notes or photos app, and for any action that cannot be undone: deleting a project, leaving a group, resetting data.

On phones

The same button, 252 pixels wide at most and 62 tall: it has touch-action none, no text selection and no long-press menu, so the finger can rest on it without the phone doing anything else.

With reduced motion

No advancing wash: two presses take the place of the long one, the first changes the line below to “Press again to empty”, the second empties and the words change at once. The demo does not move by itself.

Pitfalls

  • Files and megabytes are made up and nothing gets deleted: in a real app the deletion starts at the end of the press and the server’s answer decides whether to say “Trash emptied”.
  • From the keyboard Space and Enter are held like the finger; the key’s auto-repeat has to be ignored (e.repeat), or the press starts again at every tick.
  • The pointer has to be captured (setPointerCapture): without it, slipping a little off the button the release never arrives.
  • The press also ends if the button loses focus, or it stays halfway.
  • Screen reader users hear “Hold to empty” as the button’s description and, at the end, how much space came back.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 5.1 KB; the libraries: GSAP 28 KB.

Testing

Tested on 22 November 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