
The elastic button
Buttons, Hover, Text
The payment step of a premium online shop, on black: a smoked glass panel with three real cards stacked as in a digital wallet (brushed graphite, copper, the indigo glass of a wallet) and the three rows to choose from below. Picking one, the two cards step aside, trade places and the new one lands in front on a spring; the glass pill slides onto the row, the card's colour spreads under the panel, and the light follows the pointer on the metal and along the edge. Pay works with a beam of light running round the button and ends on Payment complete.
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>
<!--
"Swapping payment cards" 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 payment method with the cards that trade places</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 payment step of an online shop's checkout. Above, the wallet: the three ways to pay as real cards in a
stack, the chosen one in front. Picking another row, the two cards step aside, trade places and the new one
lands in front on a spring; the light on the metal follows the pointer -->
<section class="pay" data-card aria-label="Payment method">
<span class="pay__glow" data-glow aria-hidden="true"></span>
<span class="pay__grain" aria-hidden="true"></span>
<header class="pay__head">
<h1 class="pay__title">Payment method</h1>
<p class="pay__total"><span class="pay__total-label">Total</span><strong class="pay__total-sum" data-total>$248.00</strong></p>
</header>
<div class="wallet" data-wallet aria-hidden="true">
<span class="wallet__floor" data-floor></span>
<div class="cc" data-cc="graphite">
<div class="cc__body" data-body>
<div class="cc__face cc--graphite">
<span class="cc__brand">Norvik</span>
<svg class="cc__mark" viewBox="0 0 24 16"><path d="M2 14L9 2h4L6 14zM11 14l7-12h4l-7 12z"/></svg>
<svg class="cc__chip" viewBox="0 0 30 22"><rect x="0.5" y="0.5" width="29" height="21" rx="4.5"/><path d="M0.5 8h9M0.5 14h9M20.5 8h9M20.5 14h9M9.5 0.5v21M20.5 0.5v21M9.5 11h11"/></svg>
<svg class="cc__waves" viewBox="0 0 16 18"><path data-wave d="M3 5.2a5 5 0 0 1 0 7.6"/><path data-wave d="M6.6 3a8.2 8.2 0 0 1 0 12"/><path data-wave d="M10.2 1a11.4 11.4 0 0 1 0 16"/></svg>
<span class="cc__holder">Mira Lane</span>
<span class="cc__digits">4242</span>
<span class="cc__sheen"></span>
</div>
</div>
<span class="cc__dim" data-dim></span>
</div>
<div class="cc" data-cc="copper">
<div class="cc__body" data-body>
<div class="cc__face cc--copper">
<span class="cc__brand">Aurel</span>
<svg class="cc__mark" viewBox="0 0 24 16"><path d="M12 1.5l6.5 13h-13z"/></svg>
<svg class="cc__chip" viewBox="0 0 30 22"><rect x="0.5" y="0.5" width="29" height="21" rx="4.5"/><path d="M0.5 8h9M0.5 14h9M20.5 8h9M20.5 14h9M9.5 0.5v21M20.5 0.5v21M9.5 11h11"/></svg>
<svg class="cc__waves" viewBox="0 0 16 18"><path data-wave d="M3 5.2a5 5 0 0 1 0 7.6"/><path data-wave d="M6.6 3a8.2 8.2 0 0 1 0 12"/><path data-wave d="M10.2 1a11.4 11.4 0 0 1 0 16"/></svg>
<span class="cc__holder">Mira Lane</span>
<span class="cc__digits">0917</span>
<span class="cc__sheen"></span>
</div>
</div>
<span class="cc__dim" data-dim></span>
</div>
<div class="cc" data-cc="halo">
<div class="cc__body" data-body>
<div class="cc__face cc--halo">
<span class="cc__brand">Halo Pay</span>
<svg class="cc__mark" viewBox="0 0 24 16"><path d="M12 2.2a5.8 5.8 0 1 1 0 11.6a5.8 5.8 0 1 1 0-11.6zM12 5.4a2.6 2.6 0 1 0 0 5.2a2.6 2.6 0 1 0 0-5.2z" fill-rule="evenodd"/></svg>
<svg class="cc__face-id" viewBox="0 0 24 24"><path d="M3 8V5.5A2.5 2.5 0 0 1 5.5 3H8M16 3h2.5A2.5 2.5 0 0 1 21 5.5V8M21 16v2.5a2.5 2.5 0 0 1-2.5 2.5H16M8 21H5.5A2.5 2.5 0 0 1 3 18.5V16M8.5 9v1.5M15.5 9v1.5M12 9v4.2h-1M9 16.2c1.8 1.3 4.2 1.3 6 0"/></svg>
<svg class="cc__waves" viewBox="0 0 16 18"><path data-wave d="M3 5.2a5 5 0 0 1 0 7.6"/><path data-wave d="M6.6 3a8.2 8.2 0 0 1 0 12"/><path data-wave d="M10.2 1a11.4 11.4 0 0 1 0 16"/></svg>
<span class="cc__holder">Mira Lane</span>
<span class="cc__digits cc__digits--word">Wallet</span>
<span class="cc__sheen"></span>
</div>
</div>
<span class="cc__dim" data-dim></span>
</div>
</div>
<div class="methods" role="radiogroup" aria-label="Pay with" data-methods>
<span class="methods__pill" data-pill aria-hidden="true"></span>
<button class="method" type="button" role="radio" aria-checked="true" data-method="graphite">
<span class="method__thumb cc--graphite" aria-hidden="true"></span>
<span class="method__text"><span class="method__name">Norvik Graphite</span><span class="method__sub">Ends in 4242 · 08/28</span></span>
<span class="method__tick" aria-hidden="true"><svg viewBox="0 0 20 20"><circle class="tick__ring" cx="10" cy="10" r="8.5"/><circle class="tick__fill" data-fill cx="10" cy="10" r="9"/><path class="tick__check" data-check pathLength="1" d="M6.2 10.3l2.6 2.6 5-5.4"/></svg></span>
</button>
<button class="method" type="button" role="radio" aria-checked="false" data-method="copper">
<span class="method__thumb cc--copper" aria-hidden="true"></span>
<span class="method__text"><span class="method__name">Aurel Copper</span><span class="method__sub">Ends in 0917 · 02/27</span></span>
<span class="method__tick" aria-hidden="true"><svg viewBox="0 0 20 20"><circle class="tick__ring" cx="10" cy="10" r="8.5"/><circle class="tick__fill" data-fill cx="10" cy="10" r="9"/><path class="tick__check" data-check pathLength="1" d="M6.2 10.3l2.6 2.6 5-5.4"/></svg></span>
</button>
<button class="method" type="button" role="radio" aria-checked="false" data-method="halo">
<span class="method__thumb cc--halo" aria-hidden="true"></span>
<span class="method__text"><span class="method__name">Halo Pay</span><span class="method__sub">Confirm with Face ID</span></span>
<span class="method__tick" aria-hidden="true"><svg viewBox="0 0 20 20"><circle class="tick__ring" cx="10" cy="10" r="8.5"/><circle class="tick__fill" data-fill cx="10" cy="10" r="9"/><path class="tick__check" data-check pathLength="1" d="M6.2 10.3l2.6 2.6 5-5.4"/></svg></span>
</button>
</div>
<button class="paybtn" type="button" data-pay>
<span class="paybtn__beam" data-beam aria-hidden="true"></span>
<span class="paybtn__face" data-payface>
<span class="paybtn__label" data-label="idle">
<svg class="paybtn__icon" viewBox="0 0 16 16" aria-hidden="true"><rect x="3.2" y="7" width="9.6" height="7" rx="1.8"/><path d="M5.4 7V5.2a2.6 2.6 0 0 1 5.2 0V7"/></svg>
<span>Pay <span data-sum>$248.00</span></span>
</span>
<span class="paybtn__label" data-label="busy"><span class="paybtn__shimmer">Processing</span></span>
<span class="paybtn__label" data-label="done">
<svg class="paybtn__icon paybtn__icon--done" viewBox="0 0 16 16" aria-hidden="true"><path data-donecheck pathLength="1" d="M3.4 8.4l3 3 6.2-6.6"/></svg>
<span>Payment complete</span>
</span>
</span>
</button>
</section>
<p class="sr" aria-live="polite" data-live></p>
</main>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
<script src="script.js"></script>
</body>
</html>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.
43 values to change
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 “Swapping payment cards” from Animorio and fit it into my siteEvery card is .cc, moved by GSAP in the stack, holding .cc__body, tilted by GSAP toward the pointer, and inside that .cc__face, drawn by CSS: this way the stack's transform, the tilt and the materials never wipe each other out. The materials are layered gradients: one pixel repeating lines for the brushing, a radial light in the corner and a 135 degree gradient.
Place i in the stack is y = −i times a tenth of the height, scale 1 − 0.075·i and a dark veil at opacity 0.38·i. The order is a list: the chosen card goes to the head, the previous one right after it, and every zIndex comes from there.
A timeline takes the front card to the left and the chosen one to the right by a fifth of the width in 0.26 s, turning them four degrees in opposite directions. At the widest point a call resets the zIndex from the new order, then the chosen card comes back to the middle with back.out(1.7) and the others slide to their places in the stack with power3.out.
The pointer (or the walk on its own, moving the target with GSAP) is the target of a spring integrated by hand, stiffness 120 and damping 15, with the step capped at 1/30 s. Every frame writes --mx and --my on the panel, which move the lit edge (a radial gradient with a mask that keeps only the edge's pixel), and --sx on the front card's sheen; the loop stops when the spring is still.
The beam is a conic-gradient just larger than the button, behind its face, turned by an --a variable that GSAP takes from 0 to 720 degrees. The three labels share one grid cell, leaving upwards and coming in from below; the check draws itself with pathLength 1 and stroke-dashoffset.
| Name | File | Default | What it changes |
|---|---|---|---|
TOTAL | script.js | 248 | The order total, in dollars. |
SHUFFLE | script.js | 0.2 | How far the two cards step aside to trade places, as a share of the card's width. |
LIFT | script.js | 4 | How much they turn while they step aside, in degrees. |
SPRING | script.js | 1.7 | How far the new card passes the mark landing in front. |
TILT | script.js | 5 | How much the front card leans toward the pointer, in degrees. |
PROCESSING | script.js | 1.5 | How long the payment works before it is complete, in seconds. |
SPEED | script.js | 1 | 2 = the walk on its own twice as fast, 0.5 = half. |
LOOP | script.js | true | Repeats the walk on its own. |
For the checkout of a high end online shop, a fashion or design brand, a subscription app: the step where you choose what to pay with, when the saved cards should look like the customer's own cards.
The same animation with adapted sizes: the panel is almost as wide as the screen, the cards and the rows take their height from the window, and a finger picks the row and brings the light where it touches.
The cards do not move: the stack changes order at once and the new card fades in, the pill fades out and back in on the row, the card does not tilt and the button's beam stays still; Pay's labels change with a fade.
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.
Tested on 1 November 2026
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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.