Skip to content
animorio
IT
All components

Nights stepper

Counters, PhysicsGSAP, CSS onlyMediumCompressed weight: Demo 9.1 KBGSAP 28 KBFreeDownload the zip

One stepper, one gesture, in the simple style of product interface pieces: how many nights in a hotel, with a minus, a plus and a big number. Underneath, a thin line runs from the check-in to the check-out: every night more stretches it by one notch on a spring, its end lands a pixel past and settles, leaning slightly as it runs, and the check-out date at the far end rolls to the new day, only in the parts that change.

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>
<!--
  "Nights stepper" 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 nights stepper with the sliding check-out</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">
    <!-- how many nights in a hotel: minus, the number, plus. Under it a thin line runs from the check-in to the
         check-out; every night more stretches it by one notch on a spring, and the check-out date at the far end rolls
         to the new day. The ticks, the line and the dates are drawn by the script -->
    <div class="stay" data-stay>
      <p class="stay__label" id="stay-label" data-label><span>Nights</span></p>

      <div class="stay__row">
        <button class="stay__btn" type="button" aria-label="One night less" data-less>
          <span class="stay__btn-in" aria-hidden="true">
            <svg viewBox="0 0 44 44"><path d="M15.5 22h13"/></svg>
          </span>
        </button>

        <div class="stay__value" role="spinbutton" tabindex="0" aria-labelledby="stay-label" aria-valuemin="1" aria-valuemax="10" aria-valuenow="3" aria-valuetext="3 nights" data-value>
          <span class="stay__slot stay__slot--num" aria-hidden="true" data-num></span>
        </div>

        <button class="stay__btn" type="button" aria-label="One night more" data-more data-autoclic>
          <span class="stay__btn-in" aria-hidden="true">
            <svg viewBox="0 0 44 44"><path d="M15.5 22h13M22 15.5v13"/></svg>
          </span>
        </button>
      </div>

      <svg class="stay__track" data-track aria-hidden="true">
        <path class="stay__rest" data-rest/>
        <g data-ticks></g>
        <path class="stay__fill" data-fill/>
        <path class="stay__start" data-start/>
        <path class="stay__end" data-end/>
      </svg>

      <div class="stay__dates" aria-hidden="true">
        <p class="stay__date">
          <span class="stay__small">Check-in</span>
          <span class="stay__day" data-in></span>
        </p>
        <p class="stay__date stay__date--out">
          <span class="stay__small">Check-out</span>
          <span class="stay__day" data-out></span>
        </p>
      </div>

      <p class="stay__said" aria-live="polite" data-said></p>
    </div>
  </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.

22 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 “Nights stepper” 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 white, alone in the middle, there is the nights stepper of a hotel booking: on top the word «Nights», under it a minus and a plus inside two thin round buttons and between them a big, light number, 3. Further down runs a very thin grey line with one notch per night: from the black check-in mark a terracotta stroke runs to the third notch and ends in a short upright stroke. Under the line, on the left «Check-in Thu 26 Nov», on the right «Check-out Sun 29 Nov». With plus the number rolls up and the stroke stretches by one notch on a spring: its end runs leaning back slightly, lands a pixel past and straightens, and the notch it passes stands up and takes the colour. The check-out date rolls to the new day, first the day and then the weekday, and when the stay crosses into December the month rolls too. With minus everything goes back the other way. At the most nights the end pushes against the last notch and comes back, the number shakes its head and the word on top becomes «Stays up to 10 nights». Holding a button makes the nights climb faster and faster; the line takes a tap or a drag to pick a night, and the arrow keys work on the number.

How it works

The end on a spring

The end of the stroke is not a tween: it is a damped spring measured in nights, integrated in small steps inside GSAP’s ticker. Plus only moves the target; the spring gets there by itself, a pixel past with SPRING’s damping, and a new press halfway restarts from the speed it has, with no jumps.

The stroke that leans

The end stroke is a two-point path: its top trails behind by the spring’s speed, so while it runs it leans back and straightens as it lands. When the spring is still the loop switches off and nothing is redrawn.

The notches that stand up

Every frame checks which notches the end has passed: the one just passed takes the colour and grows with elastic.out, the one left behind shrinks with power2. The notches follow the spring, not the number, so they stand up exactly when the end runs over them.

Only the parts that change

The check-out date is three slots, weekday, day and month, each a grid with its texts in the same cell. Only the slot that changes rolls: the old text leaves on the side the count goes, the new one lands a pixel past and settles, and the slot takes the new width with back.out. The day first, then the weekday, then the month, like a carry.

Values to change

NameFileDefaultWhat it changes
MINscript.js1The fewest nights.
MAXscript.js10The most nights, and the notches on the line.
STARTscript.js3The nights when the page opens.
CHECK_INscript.js2026-11-26The arrival day, year-month-day.
SPRINGscript.js1How springy the end of the line is: 0.5 stops dead, 2 runs past and swings back.
SPEEDscript.js1The speed of everything: 2 twice as fast, 0.5 half.
HOLDscript.js[0.42, 0.16, 0.07]Holding a button: the wait before repeating, the first gap and the shortest, in seconds.
WORDSscript.js['night', 'nights']The word for one night and for more, read out by a screen reader.
LABELscript.js['Nights', 'Stays up to {max} nights', 'At least one night']The label on top: at rest, at the most, at the fewest.

Try them in the Playground

When to use it

In the booking card of a hotel, a holiday home or a campsite, when choosing how many nights to stay: the stretching line and the rolling date say at once when you leave, without opening a calendar.

On phones

On the phone the stepper takes its width from the screen (min with 88vw) and its heights from the height too (clamp in vh); the line is recomputed on resize. There is no hover on the notches: they take a tap and a drag.

With reduced motion

Nothing moves: the end of the line jumps straight to the new night, the notches change colour, the number and the date cross-fade.

Pitfalls

  • With a tween the end restarted from rest at every press and holding a button made it stutter: with the spring the target moves and the speed stays, so the run is a single one even over ten presses.
  • Notches lit by the number stood up before the end got there: now they are checked every frame against the spring’s position.
  • The library preview’s click is a scripted click: one step per click would make the preview’s loop last thirty seconds, so it plays the whole tour (four nights up, into December, and back).
  • GSAP moves the path inside the button, not the round face: the face’s press is a CSS transform a GSAP transform would wipe out.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 1 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