Skip to content
animorio
IT
All components

Stay date picker

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

The booking card of a hotel, on white, in the style of product interface pieces: the Check-in and Check-out field opens a one-month calendar in place of the bill. Once the arrival is picked, a terracotta ribbon follows the pointer to the day under your hand on a short spring; on the second click the calendar closes, both dates roll into the field letter by letter and nights, taxes and total count up to the price.

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>
<!--
  "Stay date picker" 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 stay date picker</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 booking card of an invented hotel: the dates field opens a one-month calendar in place of the price breakdown,
         the stay is drawn as a ribbon from check-in to the day under the pointer, and on the second pick the dates roll into the field
         while nights and total count up -->
    <section class="stay" data-card aria-label="Casa Vellora booking">
      <header class="stay__head">
        <p class="stay__brand">Casa Vellora <span>Room with terrace</span></p>
        <p class="stay__rate"><b data-rate>€180</b> night</p>
      </header>

      <div class="field" data-field>
        <span class="field__pill" data-pill aria-hidden="true"></span>
        <button class="field__half" type="button" data-half="in" aria-expanded="false" aria-controls="calendario">
          <span class="field__label">Check-in</span>
          <span class="field__val" data-val="in"><span>Add date</span></span>
        </button>
        <svg class="field__arrow" viewBox="0 0 24 12" aria-hidden="true"><path d="M2 6h19M16 1.5 21 6l-5 4.5"></path></svg>
        <button class="field__half" type="button" data-half="out" aria-expanded="false" aria-controls="calendario">
          <span class="field__label">Check-out</span>
          <span class="field__val" data-val="out"><span>Add date</span></span>
        </button>
      </div>

      <div class="body" data-body>
        <div class="sum" data-sum>
          <div class="perk">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 2.5 16 5v4.6c0 3.6-2.5 6.4-6 7.9-3.5-1.5-6-4.3-6-7.9V5Z"></path><path d="m7.2 10 2 2 3.8-4" data-perk-tick></path></svg>
            <div><p class="perk__t">Free cancellation</p><p class="perk__s" data-perk><span>Cancel up to a day before check-in.</span></p></div>
          </div>
          <dl class="sum__rows" data-rows>
            <div class="sum__row"><dt data-nights-label>€180 × 0 nights</dt><dd data-sub>€0</dd></div>
            <div class="sum__row"><dt>Cleaning fee</dt><dd data-clean>€0</dd></div>
            <div class="sum__row"><dt>Taxes</dt><dd data-tax>€0</dd></div>
            <div class="sum__row sum__row--total"><dt>Total</dt><dd data-total>€0</dd></div>
          </dl>
          <button class="reserve" type="button" data-reserve><span class="reserve__txt" data-reserve-txt>Check availability</span></button>
          <p class="sum__note">You won’t be charged yet</p>
        </div>

        <div class="cal" id="calendario" data-cal role="dialog" aria-label="Choose your dates">
          <div class="cal__top">
            <button class="cal__nav" type="button" data-prev aria-label="Previous month"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10 3 5 8l5 5"></path></svg></button>
            <p class="cal__month" data-month><span></span></p>
            <button class="cal__nav" type="button" data-next aria-label="Next month"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m6 3 5 5-5 5"></path></svg></button>
          </div>
          <div class="cal__week" aria-hidden="true"><span>Mo</span><span>Tu</span><span>We</span><span>Th</span><span>Fr</span><span>Sa</span><span>Su</span></div>
          <div class="cal__clip" data-clip></div>
        </div>
      </div>
    </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>

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.

41 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 “Stay date picker” 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 sits the booking card of Casa Vellora, an invented hotel: the name with Room with terrace below it, €180 a night on the right, the grey field split into Check-in and Check-out with a thin arrow between them, and below it the bill (nights, cleaning, taxes, total), the black Check availability button and the line You won’t be charged yet. Tapping Check-in sets a white pill on the active half, the bill slides down and the month calendar opens in its place, its days arriving one after another: past days are faded and struck through, today has a thin ring. The arrow goes to the next month: the old days slide away and the new ones come in column after column, with the month name passing sideways. Once the arrival day is picked, its circle fills with terracotta with a small bounce, the date rolls into the field and the pill runs to Check-out, stretching for a moment. From there, moving over the days, a light terracotta ribbon stretches from the arrival to the day under the pointer on a short spring, wraps from week to week and pulls back if you go back; the end day has a ring in the colour. On the second click the calendar closes, the departure date rolls into the field, the bill comes back up on a spring and the figures count up to the total, while the button turns terracotta and its label, widening for a moment, becomes Reserve. Pressing it says Room held for 10 min, then goes back. A drawn pointer does it all by itself and starts again; it also really works, with mouse, touch and keyboard.

How it works

Days as numbers

Every day is the number of days since 1970 (Date.UTC divided by one day): arrival, departure and the day under the pointer compare with a less-than and a greater-than, with no time zones shifting the dates.

One ribbon per week

Under the grid of days there are six ribbon pieces, one per row. On every change the first and last day of the range in each row are found and GSAP takes the piece’s x and width to the new measures with back.out(1.5): the ribbon stretches and pulls back like an elastic band, and the pieces in later rows start 35 milliseconds later.

Two halves and a pill

The white pill sits under the two halves of the field and slides by the distance between them, measured with offsetLeft; as it runs it stretches 5% towards where it is going and back, as if taking a run-up.

Dates that roll

The new date is split into inline-block letters rising from under the edge with an 18 millisecond stagger, while the old one leaves upwards all together: the field stays 19 pixels tall and hides the rest.

A bill that counts

The four figures are values on an object that GSAP takes to the new number in 0.9 seconds; on every frame they are rewritten in euros with toLocaleString. The button changes its label with a tween of the variable font’s wdth axis widening and coming back.

Values to change

NameFileDefaultWhat it changes
NIGHTLYscript.js180The price of one night, in euros.
CLEANINGscript.js40The cleaning fee, charged once.
TAX_RATEscript.js0.08The taxes, as a share of the stay.
ACCENTscript.js#e0603aThe colour of the picked days, the ribbon and the ready button.
RIBBON_TIMEscript.js0.38The seconds of the spring of the ribbon following the pointer.
PAUSEscript.js1The seconds the autopilot waits between one gesture and the next.

Try them in the Playground

When to use it

For booking a hotel, a holiday home or a farm stay, renting a car or a bike, and anywhere a range of dates is chosen: time off in a team app, a subscription, a trip.

On phones

The card takes the width of the box minus the margins; days are 26 to 36 pixels tall with 6.6vh, so the whole month fits even in a short box, and the field and button shrink with vh. A tap does what a click does; on a phone the ribbon follows the finger to the tapped day.

With reduced motion

No springs and no slides: calendar and bill swap with a fade, the ribbon appears already at its size, dates and figures change without rolling and the drawn pointer stays hidden.

Pitfalls

  • With local dates, in some time zones daylight saving moved a day at midnight and the ribbon skipped a cell: with Date.UTC and days counted as whole numbers it no longer happens.
  • A calendar hidden with display none has no measures, and the ribbon was computed at zero: it stays on the page with visibility hidden, so offsetLeft and offsetTop are always there.
  • The ribbon piece appearing in a new row started from where the previous row’s was: it must first be set in place at zero width, then stretch.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 26 October 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