Skip to content
animorio
IT
All components

Nightly price slider

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

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.

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

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.

31 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 “Nightly price slider” 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 an almost black page, with a coral light rising from behind and a very fine grain, a single dark card with round corners, its one pixel edge catching the light at the top and a soft layered shadow. At the top Price per night, under it Lisbon · 4 nights · 2 guests, and on the right a pill switch, Night and Total. In the middle the histogram of the stays in forty four thin bars, with a dashed line and its label, Area avg €153: the average of the area. Below, the slider with two ivory handles, each with two small grooves, and over each its price in a capsule. The bars between the handles are coral, with a lighter sheen on top and a glow, and a soft light warms them from below, following the range; the ones outside are smoke grey. As a handle goes over a bar, the bar changes colour with a small elastic jump: up when it comes in, down when it leaves, so a wave runs under the hand. Pressed, a handle squeezes, rises by a pixel and takes a coral halo, and its price capsule lifts; let go, it widens again with a bounce. The handles follow the finger on a spring and stretch a little as they run. The prices and the count at the bottom, 128 stays, roll digit by digit like an odometer, and when the capsules touch they push each other. When a handle crosses the average, the label and the tick on the slider give a bump; when the whole range is under the average, Below the area average appears in coral. With Total the pill slides and every price, the average and the scale become those of the four nights. Until someone touches it, a drawn pointer drags the two handles, brings the range under the average, tries Total and puts everything back.

How it works

Always the same stays

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

Handles on a spring

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.

Bars that light up

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.

Rolling digits

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 pointer and the average

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.

Values to change

NameFileDefaultWhat it changes
LOWESTscript.js40The lowest price of a night on the scale, in euros.
HIGHESTscript.js400The highest price on the scale, shown with a plus.
STEPscript.js5How many euros a handle moves by.
NIGHTSscript.js4The nights of the stay, for the Total prices.
BARSscript.js44How many bars the histogram has.
STIFFNESSscript.js380The spring that pulls a handle to the finger: higher is quicker.
DAMPINGscript.js25Lower lets the handle pass the mark and come back.
SQUEEZEscript.js0.8How small a pressed handle gets: 1 is not at all.
SPEEDscript.js1The speed of the loop: 2 twice as fast, 0.5 half.
AUTOscript.jstrueA drawn pointer plays with the filter until someone touches it.

Try them in the Playground

When to use 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 phones

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.

With reduced motion

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.

Pitfalls

  • The pointer’s drag was a fromTo inside the timeline: its onUpdate fired as soon as the timeline was built, with the start value still empty, and the handles jumped to 40 and 60 euros. Now it is a to and onUpdate does nothing until onStart has read the start value.
  • New drum columns (95 to 140) started from 0 and for a moment it read €090: now new digits are born right and come in from below with a fade.
  • With proportional digits every drum window takes the width of the widest digit and numbers opened up (€61 2): the digits are tabular, with an unslashed zero.
  • The average capsule covered the tops of the tallest bars: the bars reach at most 82% of the chart.

Libraries

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.

Testing

Tested on 4 November 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