
The layered button
Buttons, Hover, Physics
The personal loan card of an invented bank, on black: the slider is a ruler of thin ticks. Under the handle the ticks rise as if under a lens, the ones on the left light up mint green, the handle snaps to every 500 euro on a measured spring and a pool of light follows it, mirrored on the card’s top edge too. Amount, monthly payment, interest and the button roll digit by digit, the principal and interest bar splits again, and Continue checks the offer and confirms it with a check.
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>
<!--
"Loan 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 loan slider that works out the monthly payment</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 loan card of an invented lender. The slider is a ruler of thin ticks: the ticks under the handle rise
like under a lens, the ones on the left light up, the handle snaps to every 500 euro on a spring and the
monthly payment, the interest and the button work themselves out again, digit by digit -->
<section class="card" data-card aria-label="Personal loan">
<span class="card__edge" data-edge aria-hidden="true"></span>
<header class="head">
<span class="logo" aria-hidden="true">
<svg viewBox="0 0 24 24"><path d="M5 15.5c3.2 0 4.4-7 7-7s3.8 7 7 7"></path><path d="M5 19h14"></path></svg>
</span>
<span class="head__text">
<span class="head__title">Personal loan</span>
<span class="head__meta">Selvo · pre-approved</span>
</span>
<span class="chip" data-chip>6.9% APR</span>
</header>
<p class="ask">How much do you need?</p>
<p class="amount" data-amountwrap><span class="roll" data-amount></span></p>
<div class="slider" data-slider role="slider" tabindex="0" aria-label="Loan amount"
aria-valuemin="1000" aria-valuemax="25000" aria-valuenow="8500" aria-valuetext="8,500 euro">
<div class="ruler" data-ruler>
<span class="ruler__pool" data-pool aria-hidden="true"></span>
<div class="ruler__ticks" data-ticks aria-hidden="true"></div>
<span class="ruler__base" aria-hidden="true"><span class="ruler__lit" data-lit></span></span>
<span class="handle" data-handle aria-hidden="true"><span class="handle__knob" data-knob><span class="handle__grip"></span></span></span>
</div>
<div class="scale" data-scale aria-hidden="true"></div>
</div>
<dl class="stats">
<div class="stat">
<dt>Monthly</dt>
<dd class="stat__big"><span class="roll" data-monthly></span></dd>
</div>
<div class="stat">
<dt>Term</dt>
<dd data-term></dd>
</div>
<div class="stat stat--end">
<dt>Interest</dt>
<dd><span class="roll" data-interest></span></dd>
</div>
</dl>
<div class="split" aria-hidden="true">
<span class="split__a" data-splita></span>
<span class="split__b" data-splitb></span>
</div>
<button class="go" type="button" data-go>
<span class="go__shine" data-shine aria-hidden="true"></span>
<span class="go__label" data-golabel>Continue with <span class="roll" data-goamount></span></span>
<span class="go__wait" data-gowait aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"></circle></svg>Checking your offer</span>
<span class="go__done" data-godone aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9" pathLength="1"></path></svg>Offer reserved</span>
</button>
<p class="sr" aria-live="polite" data-live></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.
31 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 “Loan slider” from Animorio and fit it into my siteThe finger moves a raw value; the target is that value pulled towards the nearest multiple of STEP: the distance, divided by half a step, is raised to 1 plus SNAP times 5. Near the tick it squashes almost to zero, halfway it jumps to the next tick: that is the snap.
The handle does not go to the target but chases it with a real spring on the GSAP ticker, acceleration equal to STIFFNESS times the distance minus DAMPING times the velocity, with the time step capped at 1/30 of a second. At 340 and 30 it overshoots by a hair and settles.
On every frame each tick rises by LENS times a Gaussian of its distance from the handle, LENS_WIDTH pixels wide, with scaleY from the bottom. The tick just reached gets a knock that fades fast. When nothing moves the loop stops writing.
The payment is the one of a fixed-rate loan, P times r over 1 minus (1 plus r) to the minus n, with r the monthly rate. Every character sits in a window one line high: the old one leaves, the new one comes in with back.out, slightly late from right to left.
| Name | File | Default | What it changes |
|---|---|---|---|
START | script.js | 8500 | The starting amount, in euro. |
MIN_AMOUNT | script.js | 1000 | The lowest loan amount, in euro. |
MAX_AMOUNT | script.js | 25000 | The highest loan amount, in euro. |
STEP | script.js | 500 | Every how many euro the handle snaps to a tick. |
APR | script.js | 6.9 | The yearly rate, in percent. |
MONTHS | script.js | 36 | The length of the loan, in months. |
SNAP | script.js | 0.75 | How hard the ticks pull the handle: 0 free, 1 a hard snap. |
STIFFNESS | script.js | 340 | The stiffness of the handle’s spring: higher, quicker. |
DAMPING | script.js | 30 | The damping of the spring: lower, more bounce. |
LENS | script.js | 2.1 | How much the ticks under the handle rise. |
LENS_WIDTH | script.js | 34 | How wide the lens that lifts the ticks is, in pixels. |
ACCENT | script.js | #5ef0b0 | The colour of the light, the lit ticks and the principal share. |
In a loan or mortgage simulator, in a bank or fintech app, in a form to apply for financing, anywhere an amount is picked between a minimum and a maximum and the monthly cost should show at once.
The card takes the width of the box minus the margins, the vertical gaps shrink with the height and the ruler measures itself again at its real width. With a finger the handle drags as with the mouse, without scrolling the page.
No spring, lens, jumps or rolling digits: the handle goes straight to the tick, the ticks on the left light up, the digits change in place and Continue 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 9.6 KB; the libraries: GSAP 28 KB.
Tested on 7 November 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.