
The layered button
Buttons, Hover, Physics
The price filter of a made-up lamp shop, on very light grey: a histogram of thin bars with the products per price band, and below it the track with two round handles. Dragging them, the bars inside the range light up and the ones outside fade, the Min and Max fields and the product count roll to the new numbers, and when the handles touch they push each other away on a small spring.
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>
<!--
"Price range 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 two-handle price range 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>
<!-- the price filter of a lamp shop: drag the two handles, the bars inside the range light up,
the fields and the product count roll to the new numbers -->
<section class="card" data-card aria-label="Price filter">
<header class="head">
<div>
<p class="head__title">Price</p>
<p class="head__meta"><span data-shop>Lumenhall</span> · desk and floor lamps</p>
</div>
<button class="reset" type="button" data-reset>Reset</button>
</header>
<div class="chart">
<div class="bars" data-bars aria-hidden="true"></div>
<div class="track" data-track>
<div class="track__rail"></div>
<div class="track__fill" data-fill></div>
<div class="handle" data-handle="0" role="slider" tabindex="0" aria-label="Minimum price"></div>
<div class="handle" data-handle="1" role="slider" tabindex="0" aria-label="Maximum price"></div>
</div>
</div>
<div class="fields">
<div class="field" data-field="0">
<span class="field__label">Min</span>
<span class="field__value"><span class="field__cur" data-cur>$</span><span class="roll" data-roll="min"></span></span>
</div>
<span class="fields__dash" aria-hidden="true"></span>
<div class="field" data-field="1">
<span class="field__label">Max</span>
<span class="field__value"><span class="field__cur" data-cur>$</span><span class="roll" data-roll="max"></span></span>
</div>
</div>
<button class="show" type="button" data-show>
Show <span class="roll roll--light" data-roll="count"></span> products
</button>
</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 “Price range slider” from Animorio and fit it into my siteThe products per band are one number per bar, a soft hump around the middle prices with a fixed seed, so the demo is the same on every visit. Each bar’s height is its count over the highest one, and the product count is the sum of the bars inside the range, counting bands cut by a handle in proportion.
Each handle has a price, a velocity and a goal. On every frame of the GSAP ticker a spring carries it towards the goal: stiffer while dragging, softer when it settles. The goal never crosses the other handle minus MIN_GAP.
If their speed brings the two handles closer than MIN_GAP, the overlap is shared between them and the pushed one gets a small backwards velocity: it backs off by a hair and its spring brings it back.
Let go, the handle’s goal becomes its price plus an eighth of a second of its velocity, rounded to STEP: the handle runs on a little and settles on a clean price.
Each digit is a 0 to 9 column inside a one-line window; when the number changes every column slides to its digit with back.out, the ones on the right a moment earlier, and the thousands comma stays still.
| Name | File | Default | What it changes |
|---|---|---|---|
SHOP | script.js | Lumenhall | The made-up shop in the line under the title. |
CURRENCY | script.js | $ | The currency symbol in the two fields. |
MAX_PRICE | script.js | 400 | The highest price on the track. |
STEP | script.js | 5 | The step the price snaps to when the handle settles. |
MIN_GAP | script.js | 40 | The minimum distance between the two handles, in the currency. |
BARS | script.js | 36 | How many bars the histogram has. |
ACCENT | script.js | #18181b | The colour of the lit bars, the track and the button. |
SPRING | script.js | 1 | How stiff the handles’ spring is. |
For the filters of an online shop, a property or travel site, a catalogue: anywhere you pick a range of prices, square metres or dates and need to see at once how many results are left.
The card takes the width of the box minus the margins and the track is measured on its real width; with a finger the handles drag without scrolling the page, and tapping the track moves the nearest handle.
No springs, bounces or rolling digits: the handles go straight where they are put, the numbers change at once and the autopilot does not run; the card fades in with a range already picked.
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.