Skip to content
animorio
IT
Back to the library

Nightly price calendar

HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.8 KBGSAP 28 KBFreeDownload the zip

The price calendar of a small hotel: every day of the month with its price for the night. The switch at the top lights up the cheapest nights one after the other, from the least expensive; a tap sets the arrival, the nights stretch as a band up to the departure and at the bottom the total rolls with the number of nights.

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 calendar" 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>Nightly price calendar with the cheapest nights lighting up</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">
    <!-- the price calendar of a small hotel: every day of the month with its price for the night; the switch at the
         top lights up the cheapest nights one after the other; a tap sets the arrival, the nights stretch as a band
         up to the departure and the total at the bottom rolls with the number of nights -->
    <section class="card" data-card aria-label="Prices per night in December">
      <header class="head">
        <div>
          <p class="head__place">Casa Lume, Lisbon</p>
          <h1 class="head__title">December</h1>
        </div>
        <button class="flex" type="button" role="switch" aria-checked="false" data-flex>
          <span class="flex__label">Cheapest nights</span>
          <span class="flex__track" aria-hidden="true"><span class="flex__knob" data-knob></span></span>
        </button>
      </header>

      <div class="week" aria-hidden="true"><span>M</span><span>T</span><span>W</span><span>T</span><span>F</span><span>S</span><span>S</span></div>
      <div class="grid" data-grid></div>

      <footer class="foot">
        <p class="foot__what"><span data-what>Pick your arrival</span></p>
        <p class="foot__total"><span data-total></span></p>
      </footer>
    </section>
    <p class="sr" data-live aria-live="polite"></p>

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

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.

23 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 calendar” 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

In the middle, on a very light blue-grey background, a white card: the hotel’s name, ‘December’ and on the right a switch, ‘Cheapest nights’. Below, the month’s grid: each day has its number and, smaller, the price for the night; Fridays and Saturdays cost more, the holidays at the end of the month more still. Tapping the switch the knob snaps on a spring and turns green, and the six least expensive nights light up one after the other, from the cheapest: behind the day a light green tile springs in and the price turns green and heavier, while the other days dim. A tap on a day makes it the arrival: a navy tile with a white number, giving a small kick. Moving the pointer over the following days, a light band stretches up to there and at the bottom the line says the dates and how many nights, with the total in euros rolling at every extra night. A second tap fixes the departure, with the other end in navy. Left alone, a pointer lights the cheapest nights, picks the three nights in a row that cost least and then puts everything back.

How it works

The grid made by the script

The script creates the days: one empty cell so the month starts on a Tuesday, then 31 buttons with number and price. The price comes from three knobs (base, weekend, holidays) plus a small fixed variation, the same at every load.

The cheapest nights

The days are sorted by price and the first CHEAP take the is-cheap class; the tile behind each scales from 0.5 to 1 with elastic.out, staggered by STAGGER in price order. So the eye sees the best night first.

Arrival, band, departure

Three numbers: arrival, departure and the day under the pointer. paint reads them and sets the classes: is-from and is-to for the navy ends with corners rounded on one side only, is-in for the band in between.

The total

At every change the prices of the nights from the arrival to the day before the departure are added up. The number rolls up if the total rises and down if it falls.

From the keyboard

The days are buttons: you reach them with Tab, focus acts as the pointer for the band and Esc clears the choice.

Values to change

NameFileDefaultWhat it changes
BASEscript.js96The price of an ordinary night, in euros.
WEEKENDscript.js34How much more Friday and Saturday cost.
HOLIDAYSscript.js58How much more it costs from the 23rd to the end of the month.
CHEAPscript.js6How many cheap nights light up.
STAGGERscript.js0.07The delay between one cheap night and the next, in seconds.
ACCENTscript.js#0f9f7cThe colour of the cheap nights.
BANDscript.js#13212bThe colour of arrival and departure.
LOOPscript.jstrueLeft alone, a pointer lights the cheap nights and picks three nights.

Try them in the Playground

When to use it

For the site of a hotel, a bed and breakfast, a holiday home or a campsite whose prices change from day to day: people with flexible dates see at once when it is worth going. The same calendar suits flights, trains and rentals.

On phones

The same card, as wide as the screen: seven columns sharing the width, slightly shorter days on short screens. With a finger you tap the arrival and then the departure; the band shows after the second tap.

With reduced motion

No springs: the cheap nights fade in all together, the knob goes straight to its place and the total changes with a fade.

Pitfalls

  • The total counts nights, not days: from the 9th to the 12th is three nights, and the price of the departure day is not in the sum.
  • The cheap nights can be told apart without colour too: the price is heavier and the other days are lighter. Green alone is not enough for those who cannot see it.
  • The euro sign and the dash between dates are written with String.fromCharCode, not as escape sequences in the code.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 5.8 KB; the libraries: GSAP 28 KB.

Testing

Tested on 14 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 animations