Skip to content
animorio
IT
All components

Tap to pay button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 7.2 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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>

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.

22 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 “Tap to pay 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 black background there are only the name of a made-up café, Kiln Coffee, with Counter 2 underneath, the dark Tap to pay pill with the contactless mark on the left and $18.40 on the right, and below a grey line: Bring your phone close. A small drawn phone, tilted, comes in from the bottom corner: it is the pointer, and with a mouse the phone follows it. The closer it gets, the more of the four contactless waves light up in mint green, the smallest first; the pill’s edge catches a green light, the button leans three pixels towards the phone and three very thin outlines appear around it, spreading and fading like a reader’s field. As it approaches, the phone straightens and drops a little. Move it away and the waves go out in reverse order. Rested on the button, the line below says Hold it there and a green ring runs all the way along the pill’s border: if the phone leaves too soon the ring runs back and the button relaxes on a spring. If it stays, the label leaves, the pill closes into a circle, fills with green, gives and bounces, the dark tick draws itself in the middle and the phone buzzes with six small taps. Then the circle opens again into a green pill reading Paid with the amount, the small tick in place of the waves, and Visa ending 4021 underneath. After a few seconds it is ready again. A click or a tap on the button pays at once, Enter too.

How it works

Distance from the edge, not the centre

Every 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.

Four waves, four thresholds

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.

The breathing field

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.

The ring along the border

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 circle and the reopening

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.

Values to change

NameFileDefaultWhat it changes
IMPORTOscript.js"$18.40"The amount written on the button and after paying.
CAMPOscript.js170From how many pixels away the button starts sensing the phone.
LETTURAscript.js0.8How long the phone has to rest on the button to pay, in seconds.
MAGNETEscript.js3How many pixels the button leans towards the phone.
RESPIROscript.js0.45How fast the field outlines spread around the button.
RIPOSOscript.js3.2How long Paid stays before the button is ready again, in seconds.
CARTAscript.js"Visa ending 4021"The card written below after paying.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • Distance must be measured from the button’s rectangle, not its centre: on a wide pill the centre is far from the ends and the waves would light up late when coming from the left or right.
  • After paying the phone is still over the button: without a flag that waits for it to move away, the button would pay a second time as soon as it is ready.
  • The ring along the border must be measured again before every reading and on resize: the pill changes width with the screen and an old rect would run off the edge.
  • The magnet moves the button: to work out where the drawn phone should go the offset has to be taken off, or the button and the phone chase each other.

Libraries

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.

Testing

Tested on 30 October 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