Skip to content
animorio
IT
Back to the library

Sticky booking bar

Scroll, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 8.3 KBGSAP + ScrollTrigger 45 KBLenis 5.3 KBFreeDownload the zip

Scroll inside the preview

The page of a made-up lake hotel, Hotel Ardesia: under the headline sits the wide booking widget, with dates, guests, the nightly price and Check availability. As you scroll the widget comes loose and on a spring shrinks into a pill fixed at the bottom centre, its fields folding into each other, with the short dates, the guests, the total rolling digit by digit from the nightly price to the whole stay, and Book now. Scroll back up and it opens wide in its place again; at the foot of the page the pill widens into the confirmation and Book now turns into Reserved with a tick.

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>
<!--
  "Sticky booking bar" 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>Hotel Ardesia · Sticky booking bar</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/opsz.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/opsz-italic.css">
  <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>
  <!-- The page of a made-up lake hotel, Hotel Ardesia. Under the headline sits the wide booking widget: dates, guests,
       price and Check availability. Scroll and the widget comes loose, folds its fields into each other and shrinks on
       a spring into a pill fixed at the bottom centre, with the short dates, the guests, the total that rolls from the
       nightly price to the whole stay, and Book now. Scroll back up and it opens wide in its place again. At the foot
       of the page the pill widens into the confirmation and Book now turns into Reserved with a tick. -->
  <header class="testata">
    <span class="marchio">Ardesia</span>
    <nav class="testata__voci" aria-label="Sections"><span>Rooms</span><span>Breakfast</span><span>Getting here</span></nav>
  </header>

  <main>
    <section class="apertura" data-apertura>
      <p class="occhiello" data-entra>Hotel Ardesia &middot; Valmora</p>
      <h1 class="titolo" data-entra>Twelve rooms <em>above</em> the lake.</h1>
      <p class="riga" data-entra>A slow house on the water, with breakfast on the terrace and a boat at the end of the garden.</p>
      <div class="posto" data-posto aria-hidden="true"></div>
    </section>

    <section class="sezione" data-sezione>
      <p class="sezione__sopra" data-riga>Rooms</p>
      <h2 class="sezione__titolo" data-riga>Every room has a window on the water.</h2>
      <ul class="stanze">
        <li data-riga><span class="stanze__nome">Lake room</span><span class="stanze__dato">24 m&sup2;</span><span class="stanze__prezzo">from &euro;180</span></li>
        <li data-riga><span class="stanze__nome">Attic</span><span class="stanze__dato">30 m&sup2;</span><span class="stanze__prezzo">from &euro;220</span></li>
        <li data-riga><span class="stanze__nome">Corner suite</span><span class="stanze__dato">38 m&sup2;</span><span class="stanze__prezzo">from &euro;260</span></li>
      </ul>
    </section>

    <section class="sezione" data-sezione>
      <p class="sezione__sopra" data-riga>Breakfast</p>
      <h2 class="sezione__titolo" data-riga>Served until eleven, on the terrace when it&rsquo;s warm.</h2>
      <ul class="stanze stanze--orari">
        <li data-riga><span class="stanze__nome">Weekdays</span><span class="stanze__prezzo">7:30 to 10:30</span></li>
        <li data-riga><span class="stanze__nome">Weekends</span><span class="stanze__prezzo">8:00 to 11:00</span></li>
      </ul>
    </section>

    <section class="sezione" data-sezione>
      <p class="sezione__sopra" data-riga>Getting here</p>
      <h2 class="sezione__titolo" data-riga>Forty minutes from the airport, and the boat stops below the garden.</h2>
    </section>

    <section class="sezione sezione--fine" data-sezione data-fine>
      <h2 class="sezione__titolo sezione__titolo--grande" data-riga>Ready when <em>you</em> are.</h2>
      <p class="sezione__nota" data-riga>Free cancellation until 48 hours before arrival.</p>
    </section>
  </main>

  <!-- the booking bar: one fixed element that sits on the widget's place, then becomes the pill -->
  <div class="barra" data-barra role="region" aria-label="Booking">
    <span class="barra__luce" aria-hidden="true"></span>

    <div class="largo" data-largo>
      <div class="campo campo--date" data-campo><span class="campo__etichetta">Check-in &middot; Check-out</span><span class="campo__valore">Dec 12 &ndash; Dec 15</span></div>
      <div class="campo campo--ospiti" data-campo><span class="campo__etichetta">Guests</span><span class="campo__valore">2 adults</span></div>
      <div class="campo campo--prezzo" data-campo><span class="campo__etichetta">Price</span><span class="campo__valore">from &euro;<span data-prezzo-largo>180</span> <small>/ night</small></span></div>
      <button class="tasto tasto--largo" type="button" data-cerca><span>Check availability</span></button>
    </div>

    <div class="stretto" data-stretto>
      <div class="stretto__date" data-pezzo><b>Dec 12 &ndash; 15</b><span>2 guests</span></div>
      <div class="stretto__totale" data-pezzo>
        <b class="totale" aria-label="Total"><span class="totale__valuta">&euro;</span><span class="totale__cifre" data-cifre></span></b>
        <span data-notti>3 nights</span>
      </div>
      <button class="tasto tasto--prenota" type="button" data-prenota data-pezzo>
        <span class="tasto__faccia" data-faccia-a>Book now</span>
        <span class="tasto__faccia tasto__faccia--fatto" data-faccia-b><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.2 8.4 6.6 11.6 12.8 4.8" pathLength="1" data-spunta/></svg>Reserved</span>
      </button>
    </div>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/ScrollTrigger.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/lenis@1.3.26/dist/lenis.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.

61 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Sticky booking bar” 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

At the top the hotel’s name, Ardesia, and the headline «Twelve rooms above the lake.», with a line. Below sits the wide booking widget: Check-in · Check-out «Dec 12 – Dec 15», Guests «2 adults», Price «from €180 / night» and the Check availability button. As you scroll, when the widget reaches the top it comes loose: on a spring it shrinks and drops into a pill fixed at the bottom centre, the fields fold towards the button and fade, the shadow grows and the edge catches the light; in the pill come up the short dates with the guests, the total and Book now, and the price rolls digit by digit from 180 to 540, three nights. Meanwhile the page’s sections go by: the rooms with their size and price, breakfast with its hours, how to get there. Scroll back up and the pill opens wide on its place again. At the foot, at «Ready when you are.», the pill widens into the confirmation and Book now presses in and becomes Reserved with a tick drawn in.

How it works

One bar, fixed

The bar is a single element with position fixed. At the top of the page there is an empty place as big as the widget: every frame the bar reads the place’s rectangle and sits on it, so it scrolls with the page as if it were inside.

Two springs

A value s goes from 0 (widget) to 1 (pill) on a hand-written spring in GSAP’s ticker; a second value c goes from 0 to 1 for the confirmation at the foot. The bar’s position, width, height and radius are a lerp between the place’s rectangle and the pill’s, centred at the bottom.

When it comes loose

The widget comes loose when its top passes 20% of the screen and comes back when it goes 24 pixels past that again: the small hysteresis keeps the bar from trembling on the line.

The fields folding

The wide layer keeps the widget’s width and is clipped by the shrinking bar; its fields slide towards the button and narrow, one after the other, as they fade. The narrow layer comes up piece by piece.

The rolling total

Every digit is a window one digit tall over a strip of 0 to 9 plus a blank: when the pill is nearly formed the columns roll to the total, right to left, on a back.out.

The confirmation

When the last section reaches the middle of the screen the pill widens; half a second later Book now presses in, the label leaves upwards and Reserved comes in from below with the tick drawing itself. Scroll back up and Book now returns.

Values to change

NameFileDefaultWhat it changes
PRICEscript.js180The price per night shown in the widget.
NIGHTSscript.js3The nights of the stay: the pill shows the price times these.
LOOSE_ATscript.js0.2Share of the screen height: when the widget’s top passes it, the bar comes loose.
PILL_WIDTHscript.js440The width of the pill at the bottom, in pixels.
SPRINGscript.js230The stiffness of the spring the bar moves on.
DAMPINGscript.js0.62The damping of the spring: lower overshoots more before settling.
CONFIRM_DELAYscript.js0.5The seconds the pill waits at the foot before Book now becomes Reserved.

Try them in the Playground

When to use it

For the page of a hotel, a holiday home, a restaurant or an event: whoever scrolls to read always has the dates, the price and the button to book within thumb’s reach, without the bar covering the page.

On phones

The widget goes on two rows (dates and guests on top, price and button below) and the pill is 94% of the screen wide and 56 pixels tall, 14 pixels from the bottom; the sections are one screen tall and keep room below for the pill. The finger’s scroll does everything.

With reduced motion

No spring, no smooth scroll and no rolling digits: the bar goes from widget to pill with a fade, the page’s rows are already in place and Reserved appears without motion.

Pitfalls

  • The fixed bar reads the place’s rectangle every frame: if it only read it on scroll, with Lenis it would lag a frame behind and tremble.
  • The bar is centred on its path (centre minus half the width) instead of starting from the left: so when the spring overshoots the pill widens on both sides and stays centred.
  • Book now’s two faces are absolutely positioned inside a fixed-width button: the hidden label cannot widen the button and push the tick off centre.
  • A blank leading digit column (180 and 540 have the same digits, but 90 and 270 do not) is set to zero width, or the euro sign stays detached.

Libraries

GSAP 3.15.0, ScrollTrigger 3.15.0, Lenis 1.3.26, Newsreader (font variabile) 5.3.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 8.3 KB; the libraries: GSAP + ScrollTrigger 45 KB, Lenis 5.3 KB.

Testing

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