Skip to content
animorio
IT
All components

Slide to confirm

Sliders, Hover, PhysicsGSAP, CSS onlyMediumCompressed weight: Demo 6.6 KBGSAP 28 KBFreeDownload the zip

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.

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

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.

26 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 “Slide to confirm” 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 very light grey background there is a white card with wide corners and a soft shadow: at the top the recipient’s initials in a circle, Noor Haddad and the account ending in 4821; below You send, the large amount $250.00 in tabular figures and Arrives instantly, no fee. At the bottom a dark pill with Slide to send $250 inside, crossed by a light that slides along, and on the left a round white handle with an arrow. Under the pointer the arrow nudges gently to the right. Grabbed, the handle sinks by a hair and the light in the words runs faster; as you drag it, a blue trail lights up behind it and the words fade while sliding a little. Let go before the end it springs back and hits the edge with a short bounce, squashing slightly; let go near the end, or flung with a quick stroke, it travels to the end by itself. There it gives a small jolt, the arrow turns into a spinning ring, the trail fills the pill, and after a moment the handle vanishes and the pill tightens on a spring into a short blue pill with a check mark drawing itself and Sent. Above, You send becomes Sent just now and the line below says Noor will see it in seconds. Then everything goes back. The autopilot pointer first tries halfway and lets go, then flings the handle to the end.

How it works

A spring on the ticker

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

The fling

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.

Trail and words

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.

The confirmation

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.

Finger, mouse and keyboard

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.

Values to change

NameFileDefaultWhat it changes
LABELscript.jsSlide to send $250The words shimmering inside the pill.
AMOUNTscript.js$250.00The amount on the card.
RECIPIENTscript.jsNoor HaddadWho gets the money (the initials in the circle follow).
ACCENTscript.js#2f6bffThe colour of the trail and the confirmation.
THRESHOLDscript.js0.9From which point of the track letting go confirms.
FLINGscript.js900The fling speed, in pixels per second, that carries the handle to the end by itself.
SPRINGscript.js1How stiff the spring that brings the handle back is.
SPIN_TIMEscript.js0.9The seconds the handle spins before the confirmation.
HOLDscript.js1.8The seconds Sent stays before starting again.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • The spring runs on the GSAP ticker rather than a separate requestAnimationFrame: that way it stops and starts with the page, and the step is capped at 34 milliseconds so a slow frame cannot blow it up.
  • Without touch-action: none on the stage a phone takes the horizontal drag as a scroll and sends pointercancel halfway.
  • The trail has the same corners as the pill and sits under the handle: if it only reached the handle’s centre, a notch would show in the first stretch.

Libraries

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.

Testing

Tested on 25 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