
The elastic button
Buttons, Hover, Text
The Tap to pay button at a café counter, on black, with a single gesture: bringing the phone close. The four contactless waves light up green one after another as the phone gets nearer, the pill’s edge catches the light, the button leans a few pixels towards it and three thin outlines spread around it, the reader’s field. With the phone resting on it a ring runs along the border; take it away too soon and the ring runs back, leave it and the pill closes into a green circle, the tick draws itself, the phone buzzes and the button opens again as Paid.
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>
<!--
"Tap to pay 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 Tap to pay button that senses the phone coming closer</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: bring it close. The contactless waves of the pay button light up one by one as the phone (the
pointer) gets nearer, the field around the button breathes, and resting the phone on the button reads it:
a ring runs along the border, the pill closes into a circle, the tick draws itself, and it opens as Paid -->
<section class="pay" data-pay aria-label="Pay at Kiln Coffee">
<p class="pay__shop"><span class="pay__name">Kiln Coffee</span><span class="pay__place">Counter 2</span></p>
<div class="pay__wrap" data-wrap>
<svg class="field" data-field aria-hidden="true">
<rect class="field__ring" data-ring-f="0"></rect>
<rect class="field__ring" data-ring-f="1"></rect>
<rect class="field__ring" data-ring-f="2"></rect>
</svg>
<button class="btn" type="button" data-btn aria-live="polite">
<span class="btn__fill" data-fill aria-hidden="true"><span class="btn__acc" data-acc><span class="btn__shine" data-shine></span></span></span>
<svg class="btn__ring" data-ring aria-hidden="true"><rect data-ring-rect pathLength="1"></rect></svg>
<span class="btn__row" data-row>
<svg class="waves" viewBox="0 0 24 24" aria-hidden="true" data-waves>
<path data-arc d="M7.2 9.2a4.2 4.2 0 0 1 0 5.6"></path>
<path data-arc d="M10.2 6.6a8 8 0 0 1 0 10.8"></path>
<path data-arc d="M13.2 4.1a11.8 11.8 0 0 1 0 15.8"></path>
<path data-arc d="M16.2 1.6a15.6 15.6 0 0 1 0 20.8"></path>
</svg>
<svg class="tick-small" viewBox="0 0 24 24" aria-hidden="true" data-tick-s><path d="M5.5 12.6 10 17l8.5-9.6"></path></svg>
<span class="btn__label" data-label>Tap to pay</span>
<span class="btn__amount" data-amount>$18.40</span>
</span>
<svg class="tick" viewBox="0 0 24 24" aria-hidden="true" data-tick><path pathLength="1" d="M5.5 12.6 10 17l8.5-9.6"></path></svg>
</button>
</div>
<p class="pay__hint" data-hint><span data-hint-text>Bring your phone close</span></p>
</section>
<div class="phone" data-phone aria-hidden="true">
<div class="phone__tilt" data-tilt>
<svg viewBox="0 0 40 74">
<rect class="phone__body" x="1" y="1" width="38" height="72" rx="8.5"></rect>
<rect class="phone__screen" x="4" y="4" width="32" height="66" rx="6"></rect>
<rect class="phone__island" x="15" y="7.2" width="10" height="3" rx="1.5"></rect>
<rect class="phone__card" data-pcard x="8" y="26" width="24" height="15" rx="2.6"></rect>
<path class="phone__chip" d="M11 30.5h4.2v3.2H11z"></path>
<rect class="phone__glint" x="5" y="5" width="3" height="40" rx="1.5"></rect>
</svg>
</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>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.
22 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 “Tap to pay button” from Animorio and fit it into my siteEvery frame the pointer’s distance from the pill’s rectangle is measured, zero when it is on top: divided by the field radius it becomes a number from zero to one, the closeness, chased smoothly so the waves never jump.
Each arc lights up in its own band of closeness, a fifth further on than the one before, mixing the dull grey and the green: so they light up in a row, the smallest first, and go out in reverse.
Three rounded rectangles in an SVG larger than the button spread from three to thirty-three pixels, a third out of phase, with a sine opacity multiplied by the closeness: far away they are invisible, close up they breathe.
A rect with pathLength 1 and the same radius as the pill, measured on its real size: stroke-dashoffset goes from 1 to 0 over the reading time, and if the phone leaves it goes back to 1 with power3.out.
The pill’s width drops to its height, the green rises underneath, the button gives and bounces with elastic.out, the tick draws itself; then the pill widens again with the label already changed, so the two labels are never visible together.
| Name | File | Default | What it changes |
|---|---|---|---|
IMPORTO | script.js | "$18.40" | The amount written on the button and after paying. |
CAMPO | script.js | 170 | From how many pixels away the button starts sensing the phone. |
LETTURA | script.js | 0.8 | How long the phone has to rest on the button to pay, in seconds. |
MAGNETE | script.js | 3 | How many pixels the button leans towards the phone. |
RESPIRO | script.js | 0.45 | How fast the field outlines spread around the button. |
RIPOSO | script.js | 3.2 | How long Paid stays before the button is ready again, in seconds. |
CARTA | script.js | "Visa ending 4021" | The card written below after paying. |
At the till of an app for cafés and shops, in a checkout that opens on the phone, on the page of a digital wallet or a card: anywhere you pay by bringing something close.
The same pill at the width of the screen, shorter if the screen is short. The finger is the phone: pressing and dragging towards the button lights the waves, and a tap on the button pays at once.
No phone, no field, no leaning: the waves stay grey and a click fades the button to green and Paid, without closing into a circle. The drawn phone does not run.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 7.2 KB; the libraries: GSAP 28 KB.
Tested on 30 October 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.