Skip to content
animorio
IT
Back to the library

Checkout button transition

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

The bag of a made-up homeware shop, with real photos of its two products, in the clean style of today’s products: press Checkout and the pill itself becomes the payment page, widening and rising until it fills everything while keeping its colour, the word Checkout flies up and becomes the title as it gains weight and width, the price flies into the Pay button and the rows of the form rise one after another. The back arrow runs it all in reverse and the page folds back into the button.

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>
<!--
  "Checkout button transition" 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>Larkfield, checkout transition</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>
  <!-- the bag of a made-up homeware shop. Press Checkout and the pill itself grows into the payment page, keeping its
       colour: the word Checkout rises and becomes the page title, the price flies into the Pay button and the fields
       come up one after another. The back arrow runs the whole thing in reverse and folds the page into the button. -->
  <main class="palco" data-palco>
    <section class="borsa" data-borsa aria-label="Your bag">
      <header class="borsa__testa">
        <span class="marchio">
          <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 15.5c2.6-6.4 6.3-9.6 12-11-1.2 5.7-4.6 9.4-11 11.6" /><path d="M7.4 12.6c1.8-1.1 3.4-2.6 4.8-4.6" /></svg>
          <span data-shop>Larkfield</span>
        </span>
        <span class="borsa__conto">Bag <span class="borsa__numero">2</span></span>
      </header>

      <ul class="righe">
        <li class="riga">
          <span class="miniatura"><img src="tazza.webp" alt="A speckled oat glazed mug on a wooden table" width="300" height="300" decoding="async"></span>
          <span class="riga__nome">Speckled mug<span class="riga__nota">Oat, 350 ml</span></span>
          <span class="riga__prezzo">$34.00</span>
        </li>
        <li class="riga">
          <span class="miniatura"><img src="strofinaccio.webp" alt="A sage checked linen tea towel, close up" width="300" height="300" decoding="async"></span>
          <span class="riga__nome">Linen tea towel<span class="riga__nota">Sage, 50 by 70 cm</span></span>
          <span class="riga__prezzo">$52.00</span>
        </li>
      </ul>

      <dl class="conti">
        <div class="conti__riga"><dt>Subtotal</dt><dd>$86.00</dd></div>
        <div class="conti__riga"><dt>Shipping</dt><dd>Free</dd></div>
      </dl>

      <button class="cassa" type="button" data-cassa>
        <span class="cassa__fondo" data-cassa-fondo></span>
        <span class="cassa__testo" data-cassa-testo>Checkout</span>
        <span class="cassa__destra">
          <span class="cassa__prezzo" data-cassa-prezzo>$86.00</span>
          <svg class="cassa__freccia" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9.5M8.6 4l4 4-4 4" /></svg>
        </span>
      </button>
    </section>

    <section class="pagina" data-pagina aria-hidden="true" aria-label="Checkout">
      <div class="pagina__fondo" data-pagina-fondo></div>
      <div class="pagina__dentro">
        <div class="barra" data-entra>
          <button class="indietro" type="button" data-indietro aria-label="Back to bag">
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3.5L5.5 8l4.5 4.5" /></svg>
          </button>
          <span class="sicuro">
            <svg viewBox="0 0 16 16" aria-hidden="true"><rect x="3.5" y="7" width="9" height="6.5" rx="1.6" /><path d="M5.6 7V5.3a2.4 2.4 0 0 1 4.8 0V7" /></svg>
            Secure checkout
          </span>
        </div>

        <h1 class="pagina__titolo" data-titolo>Checkout</h1>
        <p class="pagina__sotto" data-entra>Contact and payment, two items from <span data-shop>Larkfield</span></p>

        <div class="gruppo">
          <label class="campo" data-entra data-campo="email">
            <span class="campo__nome">Email</span>
            <span class="campo__valore"><span data-email></span><span class="cursore" data-cursore></span></span>
          </label>
          <label class="campo" data-entra data-campo="carta">
            <span class="campo__nome">Card</span>
            <span class="campo__valore">
              <svg class="chip" viewBox="0 0 22 16" aria-hidden="true"><rect x=".6" y=".6" width="20.8" height="14.8" rx="3" /><rect x="3.6" y="4.6" width="5.4" height="4.2" rx="1" /><path d="M3.6 11.6h9" /></svg>
              4242 4242 4242 4242
            </span>
          </label>
          <div class="campo campo--doppio" data-entra>
            <label class="campo__meta"><span class="campo__nome">Expiry</span><span class="campo__valore">08 / 28</span></label>
            <label class="campo__meta"><span class="campo__nome">CVC</span>
              <span class="campo__valore"><svg class="nascosto" viewBox="0 0 26 6" aria-hidden="true"><circle cx="3" cy="3" r="2.2" /><circle cx="13" cy="3" r="2.2" /><circle cx="23" cy="3" r="2.2" /></svg></span>
            </label>
          </div>
        </div>

        <div class="totale" data-entra><span>Total</span><span class="totale__cifra">$86.00</span></div>

        <button class="paga" type="button" data-paga data-entra>
          <span class="paga__fondo"></span>
          <span class="paga__testo">Pay</span>
          <span class="paga__prezzo" data-paga-prezzo>$86.00</span>
        </button>
      </div>
    </section>

    <span class="volo volo--titolo" data-volo-titolo aria-hidden="true">Checkout</span>
    <span class="volo volo--prezzo" data-volo-prezzo aria-hidden="true">$86.00</span>

    <svg class="puntatore" data-puntatore viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2l13.6 8.1-6 1.3-2.9 5.6z" /></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.

50 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 “Checkout button transition” 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 background there is the bag of Larkfield, a made-up homeware shop: the logo, two products with their thumbnails in real photos, a speckled stoneware mug on a wooden table and a sage checked linen tea towel seen up close, the subtotal, free shipping and at the bottom the black Checkout pill with the price and an arrow. Hover it and the arrow takes a small step forward. Press it and the pill sinks a little and then becomes the page: a black background of the same colour starts exactly from its shape, widens first sideways and a beat later up and down, and the round corners straighten only at the end, while the bag behind it moves back and dims. Meanwhile the word Checkout flies up to the left, grows and becomes the page title, gaining weight and width on the variable font’s axes. The rows of the page rise one after another, a pixel too far and back: the back arrow with the Secure checkout padlock, the line under the title, the group of fields with the email, the card and the expiry, the total and the white Pay button. The price from the pill flies into the Pay button just as it arrives, and the button swells for a moment to receive it. The email types itself in, with a purple caret and a purple line under the field. The back arrow runs it all in reverse: the rows leave from the bottom, the page folds back into the pill, the words fly home and the pill lands with a small elastic squash. A drawn pointer plays the whole loop by itself and steps aside as soon as you touch it.

How it works

The page starts from the pill

On click the pill is measured against the stage and the page’s black background is placed exactly on top of it, with the same height and a radius of half the height. The pill’s own background switches off in the same instant: the viewer still sees the button.

Wide first, then tall

The background widens to the full width with expo.inOut in OPEN seconds; the height starts a beat later, at 8 per cent, and the radius goes to zero with power3.in, so the corners stay round while the shape still reads as a button.

The word becomes the title

A copy of the word Checkout leaves the label’s place in the button and flies to the place of the title, already laid out and hidden: position, font size and the two axes wght and wdth move together. On arrival the copy disappears and the real title shows.

The rows and the price

The page rows rise RISE pixels, STAGGER seconds apart, with back.out(1.35): they pass the mark by a pixel and come back. The price flies into the Pay button once it has arrived, and the button swells by 3.5 per cent and settles.

In reverse

On the way back the pill is measured as if the bag were already at full size; the rows leave from the bottom in two tenths, the page folds first in height and then in width, and the pill lands with elastic.out.

Values to change

NameFileDefaultWhat it changes
SHOPscript.jsLarkfieldThe name of the shop.
EMAILscript.jsmaya@larkfield.coThe email that types itself in on the payment page.
OPENscript.js0.85How many seconds the pill takes to grow into the page.
CLOSEscript.js0.7How many seconds the page takes to fold back into the pill.
STAGGERscript.js0.06Seconds between one row of the form and the next.
RISEscript.js16How many pixels the rows rise as they come in.
SINKscript.js0.95How small the bag gets behind the page.
PAUSEscript.js2.4Seconds the demo stays on the payment page.
--scurostyle.css#121214The colour of the pill and the page.
--accentostyle.css#7b6cffThe accent: the caret, the field line, the padlock.

Try them in the Playground

When to use it

For the step from the cart to the payment in an online shop, for a button that opens a full-screen page or panel, or to show on a landing page how an app goes from a summary to the action.

On phones

The same transition with adapted sizes: the bag and the page are sized on the height too, the form rows are lower, the page fills the whole screen.

With reduced motion

No flights or movement: the page fades in with the title, the price and the email already in place, and fades out.

Pitfalls

  • The arrival title and price are already laid out and hidden with visibility, not display: that way they keep their size and the flying copy knows where to go.
  • On the way back the pill must be measured with the bag at full size (scale 1 for an instant): measured while shrunk, the page would close next to the button.
  • The rows must be reset to y 0 before measuring the Pay button, or on the second loop the price lands eight pixels too low.
  • The photo thumbnails have width and height in the html and a fixed square in the CSS: that way the row does not change height when the photo arrives, and the pill measured on click is already in place even on the first loop.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 6 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 animations