Skip to content
animorio
IT
All components

Doggy bag button

Buttons, HoverGSAP, CSS onlyEasyCompressed weight: Demo 4.8 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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>

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.

11 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 “Doggy bag 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 black pill: the icon of a box with its two flaps open and the label “Box up the rest”. Tap it and the pill tightens slightly and bounces, the flaps close turning on their hinges with a spring, the box gives a small hop and a strip of tape draws in the middle; the label rolls to “Boxing it up”. A moment later the pill turns green, the tape gives way to a tick drawing itself on the box, the label rolls to “Box on its way” and on the right a second, lighter button springs open, “Undo”, with a white line getting shorter under it. Tap “Undo” and everything goes back: the flaps reopen, the pill turns black again. If the line runs out instead, “Undo” closes and the green confirmation stays.

How it works

Four states

Idle, 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.

The flaps

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.

The time to undo

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.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#2f8f63The colour of the button once the request has gone.
UNDOscript.js3.6For how many seconds it can still be undone.
CLOSEscript.js0.7How long the box’s flaps take to close.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • The real request is best sent to the kitchen only once the time to undo has run out: that way “Undo” has nothing to chase.
  • The two buttons sit in the same pill but are two real buttons, side by side: a button inside another is not valid HTML.
  • The sent state is not told by green alone: the label and the icon change, and an aria-live region announces it.

Libraries

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.

Testing

Tested on 25 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