Skip to content
animorio
IT
All components

Grocery swap notification

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

The notification of Basketry, a made-up grocery delivery app, as a black dynamic island on white, like a Dribbble shot. Folded, it says who is shopping your order and how many items are already in the basket, with a thin ring. When an item is sold out it opens on a spring: the sold-out carton struck through, the suggested swap beside it, a line running down to the auto-approval and two actions. Approve swap slides the new carton into place, draws the tick and folds the island back with the count rolling up by one; Refund takes it off the order. Dragged sideways it flies off with the speed of the finger and Undo brings it 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>
<!--
  "Grocery swap notification" 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 grocery delivery notification with the sold-out item and the swap to approve</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>
    <!-- one gesture: answer the shopper. The black island of Basketry says who is shopping your order; it opens on a
         spring when an item is sold out, with the swap side by side. Approve swap slides the new carton into place and
         the island folds back with one more item in the basket. Drag it sideways to clear it; Undo brings it back. -->
    <div class="frame" data-wrap>
      <div class="swipe" data-swipe>
        <div class="island" data-island role="status" aria-live="polite">
          <span class="island__skin" aria-hidden="true"></span>
          <span class="island__grain" aria-hidden="true"></span>
          <span class="island__rim" aria-hidden="true"></span>
          <span class="island__sheen" data-sheen aria-hidden="true"></span>

          <!-- the compact pill -->
          <button class="pill" type="button" data-pill aria-expanded="false" aria-label="Show the update from your shopper">
            <span class="pill__app" aria-hidden="true">
              <svg viewBox="0 0 24 24"><path class="g-handle" d="M8.2 10.2 11 5.6M15.8 10.2 13 5.6"></path><path class="g-basket" d="M4.6 10.2h14.8l-1.6 7.4a1.8 1.8 0 0 1-1.8 1.4H8a1.8 1.8 0 0 1-1.8-1.4Z"></path><path class="g-slats" d="M9.6 13v3.4M14.4 13v3.4M12 13v3.4"></path></svg>
            </span>
            <span class="pill__who"><span data-shopper>Mara</span> is shopping</span>
            <span class="pill__count" aria-hidden="true">
              <span class="roll" data-roll><span class="roll__n" data-n-old>12</span><span class="roll__n" data-n-new>13</span></span>
              <span class="pill__of">of <span data-total>18</span></span>
            </span>
            <svg class="ring" viewBox="0 0 20 20" aria-hidden="true"><circle class="ring__track" cx="10" cy="10" r="7.5"></circle><circle class="ring__fill" data-ring cx="10" cy="10" r="7.5"></circle></svg>
          </button>

          <!-- the open card -->
          <div class="card" data-card aria-hidden="true">
            <div class="card__head" data-part>
              <span class="card__app" aria-hidden="true">
                <svg viewBox="0 0 24 24"><path class="g-handle" d="M8.2 10.2 11 5.6M15.8 10.2 13 5.6"></path><path class="g-basket" d="M4.6 10.2h14.8l-1.6 7.4a1.8 1.8 0 0 1-1.8 1.4H8a1.8 1.8 0 0 1-1.8-1.4Z"></path><path class="g-slats" d="M9.6 13v3.4M14.4 13v3.4M12 13v3.4"></path></svg>
              </span>
              <span class="card__titles">
                <span class="card__meta">Basketry<span class="card__sep">·</span>now</span>
                <span class="card__title" data-title>Oat milk is sold out</span>
              </span>
              <button class="card__fold" type="button" data-fold aria-label="Fold the notification">
                <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 9.8 8 6.3l3.5 3.5"></path></svg>
              </button>
            </div>

            <div class="swap" data-part data-swaprow>
              <div class="item item--gone" data-gone>
                <span class="carton" aria-hidden="true">
                  <svg viewBox="0 0 28 36"><path class="carton__body" d="M5 12.5 9 6h10l4 6.5V32a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 5 32Z"></path><path class="carton__top" d="M9 6V2.8h10V6"></path><path class="carton__fold" d="M5 12.5h18"></path><rect class="carton__band carton__band--oat" x="7.4" y="18" width="13.2" height="7.4" rx="1.2"></rect></svg>
                </span>
                <span class="item__text">
                  <span class="item__name">Oatfield Barista<span class="item__strike" data-strike aria-hidden="true"></span></span>
                  <span class="item__sub">1 L<span class="card__sep">·</span>€2.10</span>
                  <span class="item__tag">Sold out</span>
                </span>
              </div>

              <span class="swap__arrow" data-arrow aria-hidden="true">
                <svg viewBox="0 0 20 12"><path d="M1.5 6h16M13 1.6 17.5 6 13 10.4"></path></svg>
              </span>

              <div class="item item--new" data-new>
                <span class="item__halo" data-halo aria-hidden="true"></span>
                <span class="carton" aria-hidden="true">
                  <svg viewBox="0 0 28 36"><path class="carton__body" d="M5 12.5 9 6h10l4 6.5V32a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 5 32Z"></path><path class="carton__top" d="M9 6V2.8h10V6"></path><path class="carton__fold" d="M5 12.5h18"></path><rect class="carton__band carton__band--almond" x="7.4" y="18" width="13.2" height="7.4" rx="1.2"></rect></svg>
                </span>
                <span class="item__text">
                  <span class="item__name">Almondry Pure</span>
                  <span class="item__sub">1 L<span class="card__sep">·</span>€2.40</span>
                  <span class="item__tag item__tag--diff" data-diff>+€0.30</span>
                </span>
              </div>

              <span class="swap__note" data-swapnote aria-hidden="true"><svg viewBox="0 0 16 16"><path d="M3.4 8.4 6.6 11.4 12.6 4.8"></path></svg><span>In the basket<span class="swap__aisle">Dairy aisle</span></span></span>
            </div>

            <div class="card__foot" data-part>
              <span class="timer">
                <span class="timer__text"><span class="timer__long">Auto-approves</span><span class="timer__short">Auto</span> in <span data-left>0:40</span></span>
                <span class="timer__line"><span class="timer__fill" data-line></span></span>
              </span>
              <span class="actions">
                <button class="act act--ghost" type="button" data-refund><span class="act__face"><span class="act__labels"><span class="act__l" data-l="idle">Refund</span><span class="act__l" data-l="done">Refunded</span></span></span></button>
                <button class="act act--go" type="button" data-approve><span class="act__face"><span class="act__labels"><span class="act__l" data-l="idle">Approve swap</span><span class="act__l" data-l="done"><svg class="tick" viewBox="0 0 16 16" aria-hidden="true"><path data-tick d="M3.4 8.4 6.6 11.4 12.6 4.8"></path></svg>Swapped</span></span></span></button>
              </span>
            </div>
          </div>
        </div>
      </div>

      <!-- after a swipe -->
      <div class="cleared" data-cleared aria-hidden="true">
        <span class="cleared__text">Notification cleared</span>
        <button class="cleared__undo" type="button" data-undo>Undo</button>
      </div>
    </div>
  </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.

48 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 “Grocery swap notification” 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 white ground sits a black pill with fine grain and an edge catching the light at the top: the green basket icon, Mara is shopping and the 12 of 18 count with a green ring marking the part done. On the tap the pill grows on a spring, first in width then in height, its text blurs away and the three rows of the card come down one after the other out of the blur: the app and the title Oat milk is sold out, the two cartons (the sold-out one in grey, with the line drawing itself through it, the arrow swaying slightly, and the suggested one with its green edge and the price difference), then the line running down to the auto-approval with the seconds counting down, Refund and Approve swap. A light crosses the card as it opens. Approve swap: the label goes up and Swapped arrives in its place with the tick drawing itself, the sold-out carton blurs and goes, the new one slides into its place with an overshoot and In the basket appears beside it; then the card folds, the pill swells a hair and the count rolls to 13 while the ring moves on. Refund takes the item off and the total drops to 17. Dragged with a finger or the mouse the notification follows, tilting slightly; let go below the threshold it springs back, flung it flies off and Notification cleared with Undo stays in its place, bringing it back from the side it left.

How it works

One island, two faces

The island is a box with hidden overflow whose width, height and radius GSAP animates, with two slightly different back.out eases 40 milliseconds apart, so it grows sideways first and then down. The pill and the card sit inside at their final size, centred: the card is never squeezed while the island grows, it is only uncovered.

Measuring the card

The card height is measured with the card hidden but already as wide as the frame, after document.fonts.ready and on every resize: on a phone the rows are narrower and the timer reads Auto in, and the island always opens to the true size.

The swap

On the click getBoundingClientRect works out how far the new carton must move to take the sold-out one’s place, which meanwhile blurs and shrinks; the new carton arrives with a back.out and a green halo flaring and settling. The button labels are two stacked lines in a one-line window, moved up by GSAP with yPercent.

The count and the ring

The number is a small drum with two figures, the old one and the new one below, moved up by one line; the ring is an SVG circle whose strokeDashoffset follows the items picked. Meanwhile the island swells by eight pixels and comes back with elastic.out.

Swiping away

Pointer events follow the finger only after seven pixels sideways (vertically the page scrolls, touch-action: pan-y); the speed is worked out over the last six samples. Past a third of the width, or flung fast, the notification flies off with a duration that depends on the speed; below that it springs back with elastic.out. A drag does not count as a click: a capture-phase listener stops it.

Values to change

NameFileDefaultWhat it changes
SHOPPERscript.jsMaraThe name of the person shopping, in the pill.
PICKEDscript.js12The items already in the basket when the round starts.
TOTALscript.js18The items in the order.
AUTO_APPROVEscript.js40The seconds before the swap is approved by itself.
SPRINGscript.js1How springy the island is: 0.4 calm, 2 very bouncy.
HOLDscript.js2.2The seconds the autopilot leaves the card open before approving.
AUTOscript.jstrueThe automatic round, which stops at the first touch.
--accentostyle.css#4fd98aThe app green: ring, count, swap edge and button.
--isolastyle.css#0b0b0dThe black of the island.

Try them in the Playground

When to use it

In the app or site of a grocery delivery service, a supermarket or an online pharmacy, when the person picking the order finds an item sold out and asks what to do: the answer is in the notification, without opening the app.

On phones

The card takes the screen width minus 32 pixels, the cartons and buttons tighten a little and the timer reads Auto in 0:39. The finger taps like the mouse and drags the notification sideways; vertically the page scrolls as usual.

With reduced motion

No springs or slides: the pill and the card swap with a fade, the swap fades the sold-out carton out and In the basket in, the count changes without the drum and the swiped notification fades out and back.

Pitfalls

  • The pill was centred with transform: translateX(-50%) and GSAP, scaling it, wiped that translation out: now it is centred with margin auto, and the card with the translate property, which GSAP leaves alone.
  • The Swapped label was pushed down by CSS with translateY(110%): GSAP read it as pixels and added yPercent to it, so it stayed outside the window and the button looked empty. Only GSAP sets its position now.
  • The island became interactive only when the light crossing it finished, almost a second and a half after the tap: a quick click on Refund was lost. Now the open state starts at 0.72 seconds.
  • On a phone the Auto-approves in 0:39 label ended up under Refund: below 380 pixels it now reads Auto in 0:39, and in any case it truncates instead of overlapping.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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