
The layered button
Buttons, Hover, Physics
The nightly price filter of Casavela, an invented vacation rental site, in a dark premium card like a Dribbble shot. Over the two handle slider sits the histogram of prices in thin bars: the ones inside the range light up in coral with a little jump, the ones outside dim, and a warm light follows them from below. A dashed line marks the area average, which gives a bump when a handle crosses it. The handles squeeze when pressed and settle on a spring, the prices over them and the number of stays roll like a drum, and a switch goes from the price of a night to the total of the stay.
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>
<!--
"Nightly price 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 nightly price range slider with the area average</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 Casavela, an invented site of vacation rentals: a dark card with a histogram of the
prices per night, a two handle slider under it, the area average marked on the chart, rolling prices and
the number of stays that rolls too -->
<section class="filter" aria-labelledby="filter-title" data-card>
<header class="filter__head">
<div class="filter__words">
<h2 class="filter__title" id="filter-title">Price per night</h2>
<p class="filter__sub">Lisbon · <span data-nights>4</span> nights · 2 guests</p>
</div>
<div class="seg" role="radiogroup" aria-label="Show prices" data-seg>
<span class="seg__thumb" aria-hidden="true" data-seg-thumb></span>
<button class="seg__btn" type="button" role="radio" aria-checked="true" data-mode="night">Night</button>
<button class="seg__btn" type="button" role="radio" aria-checked="false" data-mode="total">Total</button>
</div>
</header>
<div class="chart" data-chart>
<span class="chart__glow" aria-hidden="true" data-glow></span>
<div class="chart__bars" aria-hidden="true" data-bars></div>
<div class="avg" aria-hidden="true" data-avg>
<span class="avg__line"></span>
<span class="avg__tag" data-avg-tag>Area avg <span class="roll" data-avg-price></span></span>
</div>
</div>
<div class="rail" data-rail>
<span class="tag" aria-hidden="true" data-tag><span class="roll" data-tag-price></span></span>
<span class="tag" aria-hidden="true" data-tag><span class="roll" data-tag-price></span></span>
<span class="track" aria-hidden="true"><span class="track__fill" data-fill></span></span>
<span class="tick" aria-hidden="true" data-tick></span>
<span class="thumb" role="slider" tabindex="0" aria-label="Minimum price per night" data-thumb>
<span class="thumb__body" data-body><span class="thumb__grip"></span></span>
</span>
<span class="thumb" role="slider" tabindex="0" aria-label="Maximum price per night" data-thumb>
<span class="thumb__body" data-body><span class="thumb__grip"></span></span>
</span>
</div>
<div class="axis" aria-hidden="true">
<span class="roll" data-axis-lo></span>
<span class="roll" data-axis-hi></span>
</div>
<footer class="filter__foot">
<div class="foot__words">
<p class="count"><span class="roll" data-count></span> <span class="count__word">stays</span></p>
<p class="deal" data-deal>
<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M2.4 4.2L6 7.8l3.6-3.6"/></svg>
<span>Below the area average</span>
</p>
</div>
<button class="show" type="button" data-show><span class="show__face" data-show-face>Show stays</span></button>
</footer>
<p class="sr" aria-live="polite" data-live></p>
</section>
<svg class="pointer" viewBox="0 0 24 24" aria-hidden="true" data-pointer>
<path d="M5 3.2l13.6 8.3-6 1.2-3.1 5.6z"/>
</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 “Nightly price slider” from Animorio and fit it into my siteThe 408 prices come from a random generator with a fixed seed, two gaussian groups (flats around 118 euros, villas around 245): the same histogram, the same average and the same poster every time. The bars are flex spans with their height as a share of the count, and inside each a second coral span whose opacity is all GSAP changes.
The chosen value snaps to steps of STEP euros; the drawn handle chases it with a spring integrated by hand on gsap.ticker (STIFFNESS and DAMPING, time step at most 1/30 s) and stretches in scaleX with its speed. Press and release live on the handle’s child: a smaller scale and one pixel up on press, elastic.out on release, so the drag spring and the touch spring never fight.
Every frame each bar’s centre is compared with the two drawn handles (not the values), so bars change as the handle really passes over them. Only when one changes state does its fade start, with a fromTo of scaleY from 1.14 (coming in) or 0.86 (leaving) to 1 with elastic.out: that is the wave under the hand.
Each digit is a window 1em tall over a 0-9 column, moved with yPercent. When the shape of the number changes (95 to 140, or the comma of the total) the columns are rebuilt starting from the old digits aligned right, and new ones come in from below. The price capsules are measured after every change and, when they touch, push each other away by half.
The loop is a timeline that starts on the load event: the pointer goes to the handles with coordinates worked out at the start of each leg, presses and drags them calling the same functions as the real hand. When a value crosses the average the label and the tick bump; Below the area average comes in with back.out. At the first real touch the timeline stops.
| Name | File | Default | What it changes |
|---|---|---|---|
LOWEST | script.js | 40 | The lowest price of a night on the scale, in euros. |
HIGHEST | script.js | 400 | The highest price on the scale, shown with a plus. |
STEP | script.js | 5 | How many euros a handle moves by. |
NIGHTS | script.js | 4 | The nights of the stay, for the Total prices. |
BARS | script.js | 44 | How many bars the histogram has. |
STIFFNESS | script.js | 380 | The spring that pulls a handle to the finger: higher is quicker. |
DAMPING | script.js | 25 | Lower lets the handle pass the mark and come back. |
SQUEEZE | script.js | 0.8 | How small a pressed handle gets: 1 is not at all. |
SPEED | script.js | 1 | The speed of the loop: 2 twice as fast, 0.5 half. |
AUTO | script.js | true | A drawn pointer plays with the filter until someone touches it. |
For the search filters of a vacation rental, hotel or travel booking site, and in general any listing with a price (rentals, tickets, shops): it shows where the prices are before choosing, how many results are left and whether the chosen range is under the average.
On the phone the card is 88% of the screen wide and the chart gets lower with the window’s height; the handles are caught by the finger even touching near them, on the chart or the track, and the rest is the same.
Nothing moves: the handles go straight to their place, the digits change in place, the bars light up and dim with a fade only, the pointer is hidden and the average line fades in.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 10 KB; the libraries: GSAP 28 KB.
Tested on 4 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.