Skip to content
animorio
IT
Back to the library

Bar happy hour

Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 5.2 KBGSAP 28 KBFreeDownload the zip

A bar’s happy hour, to try by dragging the time of day: when the time enters the band from 5 to 7 pm, the band on the track lights up, a warm light rises on the card, the state goes from “Starts in 20 min” to “On now” and the prices roll one after the other to the lower ones, with the full price left struck through beside them. After 7 pm everything goes back.

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>
<!--
  "Bar happy hour" 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>Bar happy hour</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 happy hour of a bar: drag the time of day and, when it enters the happy hour, the band lights up,
         the prices roll to the lower ones and the time left counts down -->
    <section class="hh" data-hh aria-labelledby="hh-title">
      <header class="hh__head">
        <span class="hh__name"><b id="hh-title">Bar Lumen</b><span>Happy hour, every day</span></span>
        <span class="hh__clock" aria-hidden="true"><b data-clock>16:40</b></span>
      </header>

      <p class="hh__state" aria-live="polite"><span data-state>Starts in 20 min</span></p>

      <div class="hh__time">
        <div class="hh__track" aria-hidden="true">
          <i class="hh__band" data-band></i>
          <i class="hh__knob" data-knob></i>
        </div>
        <input class="hh__range" type="range" data-range min="960" max="1200" step="5" value="1000" aria-label="Time of day">
        <div class="hh__hours" aria-hidden="true"><span>16:00</span><span>17:00</span><span>18:00</span><span>19:00</span><span>20:00</span></div>
      </div>

      <ul class="hh__menu">
        <li class="hh__drink" data-drink data-was="11" data-now="7"><span class="hh__what"><b>Negroni</b><span>Gin, bitter, vermouth</span></span><span class="hh__price"><s data-was-el>€11</s><span class="hh__roll"><b data-price>€11</b></span></span></li>
        <li class="hh__drink" data-drink data-was="9" data-now="6"><span class="hh__what"><b>Spritz</b><span>Bitter, prosecco, soda</span></span><span class="hh__price"><s data-was-el>€9</s><span class="hh__roll"><b data-price>€9</b></span></span></li>
        <li class="hh__drink" data-drink data-was="6" data-now="4"><span class="hh__what"><b>Draught lager</b><span>Half litre</span></span><span class="hh__price"><s data-was-el>€6</s><span class="hh__roll"><b data-price>€6</b></span></span></li>
      </ul>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.

33 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 “Bar happy hour” 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 a brown ground that is almost black, a dark card: “Bar Lumen”, “Happy hour, every day” and on the right the large time, “16:40”. Below, a state line, “Starts in 20 min”; then the day’s track from 4 to 8 pm, with the happy hour band in dim orange between 5 and 7 and a white knob to drag. At the bottom three drinks with their prices: “Negroni €11”, “Spritz €9”, “Draught lager €6”. Drag the knob and the large time changes in five-minute steps and the state counts how long is left. As soon as it passes 5 pm the band lights up in full orange with a halo, a warm light comes down from the top of the card, the time gives a small start, the state turns orange, “On now, ends in 1 h 55 min”, and the three prices roll one after the other to “€7”, “€6”, “€4” in orange, while the full price appears struck through beside them. After 7 pm the light goes out, the prices come back up and the state says “Over for today, back tomorrow at 17:00”. The same with the keyboard arrows.

How it works

Everything is read from the time

The state is one number, the minutes since midnight, and it is the value of a real range input: a function works out the time, the knob’s position, the sentence and whether the happy hour is on.

The edge

Only when the time crosses the start or the end does the change run: a class on the card lights band and state, and the prices change with a delay of STAGGER between one row and the next.

The prices

The price rolls inside a one-line window; the full one is a second, struck element appearing beside it, so the saving shows.

The light

A soft halo above the card, whose opacity is a CSS variable taken from 0 to GLOW in almost a second.

The knob

The real input sits over the track, transparent: it drags, works from the keyboard and is read by those who cannot see; the drawn knob follows it in percent.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#ff9a3dThe colour of the happy hour: band, state, lower prices and light.
FROMscript.js17The hour the happy hour starts (between 4 and 8 pm).
TOscript.js19The hour it ends.
STAGGERscript.js0.09The delay between one price and the next when they change.
GLOWscript.js1How strong the warm light is: 0 = none, 1.6 = a lot.
LOOPscript.jstrueLeft alone, the demo’s pointer drags the time into and out of the happy hour.

Try them in the Playground

When to use it

On the site or app of a bar, a pub, a restaurant with aperitivo or a hotel with a bar: in the menu, where prices change at certain hours. On a real site the time is now and the slider is not there, or is used to show what changes.

On phones

The same card, as wide as the screen minus the margins: the knob drags with a finger on a strip 32 pixels tall, the drink rows are 46 tall and long descriptions are cut with an ellipsis.

With reduced motion

No rolling prices and no light rising slowly: crossing the start or the end, band, state, prices and struck price change in one step. The knob still drags. The demo does not move by itself.

Pitfalls

  • Bar, drinks and prices are made up: on a real site the time comes from the viewer’s clock (in the venue’s time zone) and the prices from the menu.
  • The happy hour is not told by colour alone: the state writes it, with how long until it ends, and the full price stays struck through beside the new one.
  • The state sentence changes on every step of the slider without rolling: with an animation every five minutes it could no longer be read.
  • The change runs only when the edge is crossed, not on every movement: otherwise the prices would keep starting to roll.
  • FROM and TO stay inside the 4 to 8 pm track and at least half an hour apart: the script corrects them.
  • The knob is a slider’s knob, not a status light: underneath there is a real range input.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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