
The layered button
Buttons, Hover, Physics
A café bill, on white: under the subtotal a tip slider that moves freely between the marks and gets pulled in near 10, 15, 18 and 20%, as if by a magnet. On every snap the mark lights up and the handle gives a small bounce; tip and total roll digit by digit, the percentage label chases the handle a beat late, Custom opens a field and Pay confirms with a check. One gesture, in the style of product micro-interactions.
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>
<!--
"Tip slider" 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 tip slider that snaps to percentages</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 bill of a café: the tip slider moves freely between the marks and gets pulled in near them,
like a magnet; tip and total roll, Custom opens a field, Pay confirms with a check -->
<section class="card" data-card aria-label="Your bill">
<header class="head">
<div class="mark" aria-hidden="true">
<svg viewBox="0 0 24 24"><path d="M6 9h10v4.5a5 5 0 0 1-5 5 5 5 0 0 1-5-5Z"></path><path d="M16 10.5h1.4a2.2 2.2 0 0 1 0 4.4H15.6"></path><path d="M9 4.5c0 1.2 1 1.4 1 2.6M12.4 4.5c0 1.2 1 1.4 1 2.6"></path></svg>
</div>
<div class="head__text">
<p class="head__title">Lindell Café</p>
<p class="head__meta">Table 7 · 4 items</p>
</div>
<p class="head__time">12:40</p>
</header>
<div class="row">
<span class="row__label">Subtotal</span>
<span class="row__value" data-sub>$39.33</span>
</div>
<div class="tip">
<div class="tip__head">
<span class="row__label">Tip</span>
<button class="custom" type="button" data-custom aria-expanded="false">Custom</button>
<span class="tip__amount roll" data-tipamount aria-live="polite"></span>
</div>
<div class="slider" data-slider role="slider" tabindex="0" aria-label="Tip" aria-valuemin="5" aria-valuemax="25" aria-valuenow="15">
<div class="bubble" data-bubble aria-hidden="true"><span class="bubble__in roll" data-bubbletext></span></div>
<div class="rail" data-rail>
<div class="rail__track"><div class="rail__fill" data-fill></div></div>
<div class="rail__notches" data-notches></div>
<div class="handle" data-handle><span class="handle__knob" data-knob></span></div>
</div>
<div class="marks" data-marks aria-hidden="true"></div>
</div>
<div class="field" data-field>
<label class="field__in">
<span class="field__label">Custom tip</span>
<input class="field__input" data-input type="text" inputmode="numeric" maxlength="2" value="22" aria-label="Custom tip in percent">
<span class="field__unit">%</span>
</label>
</div>
</div>
<div class="row row--total">
<span class="row__label">Total</span>
<span class="total roll" data-total></span>
</div>
<button class="pay" type="button" data-pay>
<span class="pay__fill" data-payfill></span>
<span class="pay__label" data-paylabel>Pay <span class="roll" data-payamount></span></span>
<span class="pay__wait" data-paywait aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"></circle></svg></span>
<span class="pay__done" data-paydone aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9" pathLength="1"></path></svg>Paid</span>
</button>
<p class="note">Tips go to the whole team.</p>
</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.
27 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 “Tip slider” from Animorio and fit it into my siteThe finger moves a raw value; the handle sits on the value bent towards the nearest mark. Within MAGNET points the distance d becomes d times (d over MAGNET) squared: near the mark it shrinks a lot, at the edge of the zone it stays the same, so there is no jump but a pull.
When the handle is less than a tenth of a point from a mark, the mark grows from the centre with back.out and the handle squashes and comes back with an elastic. Let go within MAGNET points, a spring takes it onto the mark.
Every character sits in a window one line high: when it changes, the old one leaves upwards and the new one comes in from below, or the other way when the number drops, with a small delay from right to left.
The label above the handle chases the value with 1 minus e to the minus dt times BUBBLE_LAG on the GSAP ticker: it always arrives a moment later.
| Name | File | Default | What it changes |
|---|---|---|---|
SUBTOTAL | script.js | 39.33 | The bill before the tip, in dollars. |
START | script.js | 15 | The starting tip, in percent. |
MARKS | script.js | 10,15,18,20 | The marks the handle snaps to, in percent. |
MAGNET | script.js | 1.8 | From how many percentage points away a mark starts pulling the handle. |
BUBBLE_LAG | script.js | 9 | How quickly the label above the handle catches up with it. |
GROW | script.js | 1.3 | How much the handle grows while it is held. |
ACCENT | script.js | #1f8a5b | The colour of the filled part, the lit marks and the payment. |
In the checkout of a café, a restaurant or a food delivery, in the till of a table-booking app, anywhere a tip is left or a percentage is picked among a few handy choices.
The card takes the width of the box minus the margins and the slider measures itself again at its real width. With a finger the handle drags as with the mouse, without scrolling the page.
No bounces or rolling digits: the handle follows at once, the label sits right above it, the digits change in place and the payment goes straight to the check. The autopilot does not start.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 8.2 KB; the libraries: GSAP 28 KB.
Tested on 27 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.