Skip to content
animorio
IT
All components

Buy now with undo button

Buttons, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.4 KBGSAP 28 KBFreeDownload the zip

The Buy now button of a made-up homeware shop, Mareld, under the card of a linen throw. One tap: the dark pill opens on a spring into a small sheet, with the saved address, the saved card and the total coming in row by row, and a warm ring that counts three seconds before the order goes. Undo in those three seconds winds the ring back, says nothing was charged and closes the sheet. If the ring closes it turns into a green tick, the status rolls to the order number, a light crosses the sheet and the product card gets its Ordered badge.

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>
<!--
  "Buy now with undo 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>The Buy now button with one tap and three seconds to undo</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the Buy now button of a made-up homeware shop, Mareld: one tap opens the pill into a small sheet with the saved
         address, the saved card and the total, and a ring counts three seconds before the order goes; Undo stops it.
         When the ring closes it becomes a tick and the order number rolls in. -->
    <div class="wrap" data-wrap>

      <!-- the product the button buys: a quiet card, the swatch drawn in CSS -->
      <article class="product" data-product>
        <div class="product__swatch" aria-hidden="true"><span class="product__fold"></span></div>
        <div class="product__text">
          <span class="product__brand">Mareld</span>
          <b class="product__name">Linen throw, Oat</b>
          <span class="product__meta">130 x 180 cm · in stock</span>
        </div>
        <span class="product__price" data-price>€64</span>
        <span class="product__badge" data-badge aria-hidden="true">
          <svg viewBox="0 0 12 12"><path d="M2.6 6.3 5 8.6 9.6 3.6"></path></svg>Ordered
        </span>
      </article>

      <!-- the button: closed it is a pill, open it is the one-tap sheet -->
      <div class="pill" data-pill>
        <span class="pill__light" data-light aria-hidden="true"></span>

        <button class="closed" type="button" data-buy aria-label="Buy now for 64 euros">
          <svg class="closed__icon" viewBox="0 0 20 20" aria-hidden="true">
            <path d="M3.5 6.5h13l-1.2 9.2a1.6 1.6 0 0 1-1.6 1.4H6.3a1.6 1.6 0 0 1-1.6-1.4Z"></path>
            <path d="M7 6.5V5.4a3 3 0 0 1 6 0v1.1"></path>
          </svg>
          <span class="closed__label" data-label>Buy now</span>
          <span class="closed__sep" aria-hidden="true"></span>
          <span class="closed__sub">1 tap</span>
        </button>

        <div class="sheet" data-sheet aria-hidden="true">
          <div class="row" data-row>
            <svg class="row__icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M3.5 9 10 3.8 16.5 9v7.2h-4.2v-4.4H7.7v4.4H3.5Z"></path></svg>
            <span class="row__text"><b>Home</b><span data-address>14 Calder Lane, Leith</span></span>
          </div>
          <div class="row" data-row>
            <svg class="row__icon" viewBox="0 0 20 20" aria-hidden="true"><rect x="2.8" y="5" width="14.4" height="10.2" rx="1.8"></rect><path d="M2.8 8.4h14.4M5.6 12.2h3"></path></svg>
            <span class="row__text"><b>Card</b><span data-card>ending 4821</span></span>
            <span class="row__total" data-total>€64.00</span>
          </div>
          <div class="foot" data-row>
            <span class="ring" aria-hidden="true">
              <svg viewBox="0 0 36 36">
                <circle class="ring__track" cx="18" cy="18" r="15"></circle>
                <circle class="ring__run" data-run cx="18" cy="18" r="15"></circle>
                <path class="ring__tick" data-tick d="M11.6 18.4 16 22.6 24.6 13.6"></path>
              </svg>
              <span class="ring__num" data-num>3</span>
            </span>
            <span class="status" aria-live="polite">
              <span class="status__win"><span class="status__now" data-status>Placing your order</span></span>
              <span class="status__sub" data-sub>Arrives Tuesday</span>
            </span>
            <button class="undo" type="button" data-undo tabindex="-1">Undo</button>
          </div>
        </div>
      </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.

34 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 “Buy now with undo 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 a white ground sit the card of a linen throw, with its drawn fabric swatch, the name and the price, and below it the dark Buy now pill with a bag drawn in line. On hover the pill rises a pixel and a soft light follows the pointer; pressed, it squashes slightly. On the tap the label goes, the pill grows on a spring into a sheet with rounded corners, the card above leans two pixels towards it, and inside come the address, the card with the total and the bottom line: the amber ring with the seconds, «Placing your order», «Arrives Tuesday» and Undo. The ring drains and the number drops with a small hop. With Undo the ring winds back, the status rolls to «Cancelled» and «Nothing was charged», and the sheet folds back into the pill. If nobody touches it, the ring turns green, the number gives way to a tick that draws itself, the status rolls to «Order placed · MR-20418», a light crosses the sheet, which swells a hair, and Ordered appears on the card; then the sheet closes.

How it works

The pill that becomes a sheet

A single element, the pill, changes width, height and radius with GSAP: closed it is 13.5 by 3.6 rem, open it takes the column’s width and the sheet’s natural height, measured for a moment at auto height before animating. Sizes are read again on resize, even with the sheet open.

The ring that counts

An SVG circle of radius 15 with a dash as long as the circumference: a three-second linear tween moves stroke-dashoffset from zero to the circumference, and at each whole second the number changes with a small hop. At the end the stroke turns green and a tick draws itself from its dasharray.

The rolling status

The status line sits in a one-line window with hidden overflow: the new text comes in from below while the old one leaves at the top and is removed, so two lines never overlap.

Undoing

Undo stops the count, winds the ring back and closes the sheet a second later: nothing goes. The autopilot tries undoing once and lets it go once, and stops at the first real click or key.

Values to change

NameFileDefaultWhat it changes
LABELscript.jsBuy nowThe label of the closed button.
ADDRESSscript.js14 Calder Lane, LeithThe saved address in the sheet.
CARDscript.jsending 4821The saved card.
TOTALscript.js€64.00The order total.
COUNTDOWNscript.js3The seconds to undo before the order goes.
SPRINGscript.js1How much the sheet bounces as it opens.
HOLDscript.js2.4The seconds the order-placed message stays before closing.
IDLEscript.js1.2The seconds before the autopilot starts.
--anellostyle.css#f2b544The colour of the counting ring.

Try them in the Playground

When to use it

On a product page or in a shop’s app, for people whose address and card are already saved: buying in one tap, but with three seconds to think again, like shops with express checkout.

On phones

Card and sheet take almost the whole width and the rows tighten; the finger taps like the mouse. Without hover the light stays off.

With reduced motion

No springs or passing light: the sheet fades in already open, the ring still drains because it is the count, the number changes without hops, the tick appears already drawn and the sheet fades closed.

Pitfalls

  • The open sheet’s height must be measured at auto height before animating: a fixed value cuts the rows when text wraps on the phone.
  • The rolling status must remove the old text when it has left, or lines pile up in the window after a few rounds.
  • The autopilot must stop at the first real click (event.isTrusted), or it keeps pressing over whoever is trying it.

Libraries

GSAP 3.15.0, Geist (font variabile) 5.3.0.

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

Testing

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