
The layered button
Buttons, Hover, Physics
A payment confirmation you drag, on very light grey: a white card with the recipient and the amount, and below a dark pill with Slide to send $250 shimmering inside. You drag the round handle: the blue trail follows it, the words fade, let go halfway it springs back with a little bounce, flung it travels to the end by itself; there it spins for a moment and the pill tightens into Sent with a check mark drawing itself.
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>
<!--
"Slide to confirm" 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 slide to confirm slider</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>
<!-- a payment card on light grey: drag the handle to the end of the pill to send the money.
Let go too early and it springs back; fling it and it travels on by itself -->
<section class="card" data-card aria-label="Send money">
<header class="card__head">
<div class="avatar" aria-hidden="true">NH</div>
<div class="who">
<p class="who__name" data-name>Noor Haddad</p>
<p class="who__meta">Penfold account ending 4821</p>
</div>
</header>
<div class="sum">
<p class="sum__label" data-status-wrap>
<span class="sum__state" data-state-send>You send</span>
<span class="sum__state sum__state--done" data-state-done>Sent just now</span>
</p>
<p class="sum__amount" data-amount>$250.00</p>
<p class="sum__note" data-note>Arrives instantly, no fee</p>
</div>
<div class="slot">
<div class="pill" data-pill role="slider" tabindex="0" aria-label="Slide to send" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
<div class="pill__fill" data-fill></div>
<span class="pill__label" data-label>Slide to send $250</span>
<div class="handle" data-handle>
<svg class="handle__arrow" data-arrow viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h12.5M12.5 6.5 18 12l-5.5 5.5"></path></svg>
<svg class="handle__spin" data-spin viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="8"></circle></svg>
</div>
<div class="pill__done" data-done aria-hidden="true">
<svg class="pill__check" data-check viewBox="0 0 24 24"><path d="M6 12.5 10.2 16.5 18 8" pathLength="1"></path></svg>
<span>Sent</span>
</div>
</div>
</div>
</section>
<svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></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>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.
26 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 “Slide to confirm” from Animorio and fit it into my siteThe handle has a position and a velocity. Once released, a spring integrates them on every frame of the GSAP ticker: towards the start it is stiff and lightly damped, so it comes back and bounces once on the edge; towards the end the goal is a quarter past the end, so the handle speeds up and stops dead against it.
While you drag, the last five points are kept with their time; the fling velocity is the difference between the first and the last. Let go past THRESHOLD, or faster than FLING pixels per second after a quarter of the track, and it confirms; otherwise it goes back.
At every position the trail widens up to the handle and lights up over the first 36 pixels, the words fade 1.7 times faster than the travel and slide 16 pixels. The light in the words is a gradient clipped to the text (background-clip: text) that GSAP slides along; while dragging it runs almost twice as fast.
One timeline: the handle’s jolt, the arrow making way for the ring that spins for SPIN_TIME seconds, then the handle vanishing, the pill and the trail tightening to 132 pixels with back.out, the check drawn with stroke-dashoffset and the state above changing. After HOLD seconds the same path in reverse.
Dragging uses pointer events with setPointerCapture, and the stage has touch-action: none, so on a phone the finger drags instead of scrolling the page. With the keyboard the arrows move the handle by a tenth and Enter sends it to the end.
| Name | File | Default | What it changes |
|---|---|---|---|
LABEL | script.js | Slide to send $250 | The words shimmering inside the pill. |
AMOUNT | script.js | $250.00 | The amount on the card. |
RECIPIENT | script.js | Noor Haddad | Who gets the money (the initials in the circle follow). |
ACCENT | script.js | #2f6bff | The colour of the trail and the confirmation. |
THRESHOLD | script.js | 0.9 | From which point of the track letting go confirms. |
FLING | script.js | 900 | The fling speed, in pixels per second, that carries the handle to the end by itself. |
SPRING | script.js | 1 | How stiff the spring that brings the handle back is. |
SPIN_TIME | script.js | 0.9 | The seconds the handle spins before the confirmation. |
HOLD | script.js | 1.8 | The seconds Sent stays before starting again. |
For actions that must not happen by mistake: sending money in a payments app, confirming an order, unlocking a rental car, deleting an account, starting a delivery. The long gesture asks for an intention a tap does not.
The card takes the width of the box minus the margins and the pill is recomputed on its real size, even when the phone turns. With a finger the handle drags and flings as with the mouse, without scrolling the page.
No spring, bounce or sliding light: the handle follows the finger and, once released, goes straight to its place; the confirmation fades in without spinning, and the autopilot only shows the states, one after another.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 6.6 KB; the libraries: GSAP 28 KB.
Tested on 25 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.