Skip to content
animorio
IT
All components

Undo countdown toast

Notifications, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.7 KBGSAP 28 KBFreeDownload the zip

The inbox of an app, on a very light grey: archiving a conversation slides the row away to the side and the list closes up on a spring, and from the bottom a dark Conversation archived toast rises with a thin ring that runs down in five seconds around the seconds left, and an Undo button. Undoing brings the row back to its place as the list opens again; archive two and the toasts stack up, and under the pointer the stack opens and the rings stop.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React tab holds the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Undo countdown toast" 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 undo toast with a countdown</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" data-stage>
    <!-- the inbox of a mail app: archiving a row slides it away, the list closes up, and an undo toast rises
         with a thin ring that runs down in five seconds around the number of seconds left -->
    <section class="inbox" data-inbox aria-label="Postwick inbox">
      <header class="inbox__head">
        <div>
          <h1 class="inbox__title">Inbox</h1>
          <p class="inbox__count" data-count>5 conversations</p>
        </div>
        <span class="inbox__app">Postwick</span>
      </header>

      <ul class="list" data-list>
        <li class="row" data-row data-name="Ines Calder">
          <span class="row__avatar" style="--tint:#e9e4ff;--ink:#5b4bd1">IC</span>
          <span class="row__body">
            <span class="row__top"><strong class="row__name">Ines Calder</strong><time class="row__time">9:41</time></span>
            <span class="row__subject">Spring catalogue proofs, last round</span>
          </span>
          <button class="row__archive" type="button" data-archive aria-label="Archive conversation with Ines Calder">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path class="lid" d="M3.5 4.8h13v3h-13z"></path><path d="M4.6 7.8v6.6a1.6 1.6 0 0 0 1.6 1.6h7.6a1.6 1.6 0 0 0 1.6-1.6V7.8M8.2 10.8h3.6"></path></svg>
          </button>
        </li>
        <li class="row" data-row data-name="Theo Marsh">
          <span class="row__avatar" style="--tint:#dff3ea;--ink:#2f7d5b">TM</span>
          <span class="row__body">
            <span class="row__top"><strong class="row__name">Theo Marsh</strong><time class="row__time">9:12</time></span>
            <span class="row__subject">Invoice 2207 for October is ready</span>
          </span>
          <button class="row__archive" type="button" data-archive aria-label="Archive conversation with Theo Marsh">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path class="lid" d="M3.5 4.8h13v3h-13z"></path><path d="M4.6 7.8v6.6a1.6 1.6 0 0 0 1.6 1.6h7.6a1.6 1.6 0 0 0 1.6-1.6V7.8M8.2 10.8h3.6"></path></svg>
          </button>
        </li>
        <li class="row" data-row data-name="Ravi Anand">
          <span class="row__avatar" style="--tint:#ffeedd;--ink:#b4612a">RA</span>
          <span class="row__body">
            <span class="row__top"><strong class="row__name">Ravi Anand</strong><time class="row__time">Yesterday</time></span>
            <span class="row__subject">Can we move Thursday’s review to 3:30?</span>
          </span>
          <button class="row__archive" type="button" data-archive aria-label="Archive conversation with Ravi Anand">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path class="lid" d="M3.5 4.8h13v3h-13z"></path><path d="M4.6 7.8v6.6a1.6 1.6 0 0 0 1.6 1.6h7.6a1.6 1.6 0 0 0 1.6-1.6V7.8M8.2 10.8h3.6"></path></svg>
          </button>
        </li>
        <li class="row" data-row data-name="June Holloway">
          <span class="row__avatar" style="--tint:#e2efff;--ink:#2e64b8">JH</span>
          <span class="row__body">
            <span class="row__top"><strong class="row__name">June Holloway</strong><time class="row__time">Yesterday</time></span>
            <span class="row__subject">Your trial ends in three days</span>
          </span>
          <button class="row__archive" type="button" data-archive aria-label="Archive conversation with June Holloway">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path class="lid" d="M3.5 4.8h13v3h-13z"></path><path d="M4.6 7.8v6.6a1.6 1.6 0 0 0 1.6 1.6h7.6a1.6 1.6 0 0 0 1.6-1.6V7.8M8.2 10.8h3.6"></path></svg>
          </button>
        </li>
        <li class="row" data-row data-name="Pablo Reyes">
          <span class="row__avatar" style="--tint:#fbe4ee;--ink:#b23d6e">PR</span>
          <span class="row__body">
            <span class="row__top"><strong class="row__name">Pablo Reyes</strong><time class="row__time">Mon</time></span>
            <span class="row__subject">Photos from the offsite, all 84 of them</span>
          </span>
          <button class="row__archive" type="button" data-archive aria-label="Archive conversation with Pablo Reyes">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path class="lid" d="M3.5 4.8h13v3h-13z"></path><path d="M4.6 7.8v6.6a1.6 1.6 0 0 0 1.6 1.6h7.6a1.6 1.6 0 0 0 1.6-1.6V7.8M8.2 10.8h3.6"></path></svg>
          </button>
        </li>
      </ul>
    </section>

    <div class="toasts" data-toasts aria-live="polite"></div>

    <template data-toast-tpl>
      <div class="toast" role="status">
        <span class="toast__ring">
          <svg viewBox="0 0 24 24" aria-hidden="true">
            <circle class="ring__track" cx="12" cy="12" r="9"></circle>
            <circle class="ring__run" cx="12" cy="12" r="9"></circle>
          </svg>
          <span class="toast__num" data-num><span class="num__cur">5</span></span>
        </span>
        <span class="toast__text">
          <strong data-msg>Conversation archived</strong>
          <span class="toast__who" data-who></span>
        </span>
        <button class="toast__undo" type="button" data-undo>
          <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M7.4 5.2 4.4 8.2l3 3M4.8 8.2h6.6a4 4 0 0 1 0 8H9"></path></svg>
          <span data-undo-label>Undo</span>
        </button>
      </div>
    </template>

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

49 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 “Undo countdown toast” 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 there is the inbox of the made up app Postwick: a white card with Inbox, 5 conversations and five rows, each with initials in a tinted round, the name, the time and the subject in grey. On hover a row darkens slightly and the time makes way for the archive button, a line drawn box whose lid lifts a little. A fake pointer moves over the second row and presses the button, which squeezes: the row slides away to the right fading out, the rows below rise to close the gap on a short spring, the card shortens with them and the count becomes 4 conversations. Meanwhile a dark toast rises from the bottom: on the left a thin lilac ring running down in five seconds around a digit that rolls from 5 to 1, in the middle Conversation archived with the person’s name in grey, on the right the Undo button with its arrow. In the last two seconds the ring turns amber. The pointer also archives the fourth row: the second toast comes in front, the first steps back, smaller, peeking out by ten pixels. Over the stack, the toasts open one above the other and every ring stops; the pointer presses Undo on the first one: Theo Marsh’s row comes back in from the right to its place with a lilac glow fading out, while the list opens again. Once the pointer leaves, the other ring starts again, reaches zero and the toast drops away: the archiving is final. Then all the rows come back and it starts again.

How it works

The list closing up

Before removing a row, the position of every other row (getBoundingClientRect) and the height of the list are noted; then the row gets display none, and each remaining row starts from its old place with a y equal to the difference and goes back to zero with back.out. The list’s height also goes from old to new, so the card shortens with the rows. Putting a row back does the same in reverse.

The ring running down

The ring is an SVG circle of radius 9 with a round cap: stroke-dasharray is the circumference, and a linear GSAP tween lasting TOAST_SECONDS takes stroke-dashoffset from zero to the full circumference. On each update the seconds left are worked out; when they change, the old digit leaves upwards and the new one rises from below. Under 1.6 seconds the stroke turns amber.

The stack

Open toasts live in a list: the newest in front, the others behind, each higher by STACK_GAP pixels, 5% smaller and more transparent. Under the pointer the stack opens: each toast rises by a full height plus 8 pixels and returns to full size, and the rings’ tweens are paused with pause(), to carry on from where they were with resume().

A real undo

Undo stops its ring’s tween, sends the toast away and puts the row back at its index: rows never leave the DOM, they only change class, so the order stays right even when undoing the first of two. The row comes back in from the right on a spring with a lilac glow fading out in a second. Ctrl Z or Cmd Z undo the last one too.

Values to change

NameFileDefaultWhat it changes
TOAST_SECONDSscript.js5The seconds in which you can still undo.
MESSAGEscript.jsConversation archivedThe toast’s message.
UNDO_LABELscript.jsUndoThe label of the undo button.
SPRINGscript.js1.4How much the rows and toasts bounce as they settle.
STACK_GAPscript.js10How many pixels each toast peeks out behind the other in the closed stack.
ACCENTscript.js#9aa6ffThe colour of the ring running down.

Try them in the Playground

When to use it

For any action that can still be undone: archiving or deleting a message, removing a product from the cart, moving a file to the bin, marking a task as done. The undo toast avoids a confirmation dialog and lets people work fast.

On phones

The card and the toast narrow to the screen’s width, the rows are also measured on the height (between 44 and 60 pixels) and everything fits in the box. Without a mouse the archive button always shows, at half light, in place of the time; a tap archives and undoes like a click.

With reduced motion

No sliding and no bouncing: the row fades and the list closes up at once, the toasts appear and leave with a fade and in the stack they are already in place. The ring still runs down and the digit changes without rolling.

Pitfalls

  • Rows are not taken out of the DOM: with display none the index stays, and undoing the first of two archived rows puts it back in the right place.
  • FLIP is measured before and after the same change, in the same frame: reading the new position after a tween makes the rows jump.
  • To stop the rings, pause() is used on their tweens and not a flag read in onUpdate: that way the time left stays exact.
  • The autopilot waits for the last toast to end with a promise resolved in its onComplete, not a fixed time: if the ring was stopped under the pointer, the loop lengthens by itself.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.7 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