Skip to content
animorio
IT
Back to the library

Weather thermometer

SVG, HoverGSAPMediumCompressed weight: Demo 6.4 KBGSAP 28 KBFreeDownload the zip

The temperature card of a made-up weather app, Fairweather, for Lisbon: a hairline thermometer whose column climbs on a spring to the degrees right now and settles after one degree too many, with the day’s low and high as two marks on the scale. Moving along the hours sends the column up or down, the big degrees roll digit by digit and the colour warms or cools within a single accent. Minimal style.

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>
<!--
  "Weather thermometer" 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>Weather thermometer</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/jetbrains-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- The temperature card of a made-up weather app, Fairweather. A hairline thermometer: the column climbs on a
       spring to the temperature right now and settles after a one-degree overshoot, the day's low and high sit on the
       scale as two thin marks. Moving along the hours below sends the column up or down to that hour, while the big
       degrees roll digit by digit and the column warms or cools within a single accent. -->
  <main class="stage">
    <article class="card" data-card aria-label="Temperature in Lisbon today">
      <header class="card__head">
        <div>
          <p class="place">Lisbon</p>
          <p class="date">Saturday, 28 November</p>
        </div>
        <p class="brand">Fairweather</p>
      </header>

      <div class="body">
        <figure class="thermo" aria-hidden="true">
          <svg viewBox="0 0 76 250" data-svg>
            <defs>
              <clipPath id="tubeClip">
                <rect x="31" y="14" width="14" height="196" rx="7"/>
                <circle cx="38" cy="219" r="17"/>
              </clipPath>
            </defs>
            <g class="ticks" data-ticks></g>
            <g class="glass">
              <rect class="glass__tube" x="30" y="13" width="16" height="200" rx="8"/>
              <circle class="glass__bulb" cx="38" cy="219" r="18"/>
              <rect class="glass__mask" x="31.2" y="200" width="13.6" height="22"/>
            </g>
            <g clip-path="url(#tubeClip)">
              <rect class="column" data-column x="34" y="120" width="8" height="100" rx="4"/>
              <circle class="bulbfill" data-bulb cx="38" cy="219" r="12"/>
            </g>
            <rect class="shine" x="32.6" y="22" width="1.4" height="120" rx=".7"/>
            <path class="shine shine--bulb" d="M27.5 213.5 a12 12 0 0 1 6 -7"/>
            <g class="mark" data-mark="high">
              <line x1="50" x2="58" y1="0" y2="0"/>
              <text x="61" y="3.5">H</text>
            </g>
            <g class="mark" data-mark="low">
              <line x1="50" x2="58" y1="0" y2="0"/>
              <text x="61" y="3.5">L</text>
            </g>
          </svg>
        </figure>

        <div class="readout" data-readout>
          <p class="big" aria-live="polite">
            <span class="sr" data-sr>15 degrees</span>
            <span class="big__digits" aria-hidden="true">
              <span class="digit" data-digit><span class="digit__roll">0 1 2 3 4 5 6 7 8 9</span></span><span class="digit" data-digit><span class="digit__roll">0 1 2 3 4 5 6 7 8 9</span></span><span class="deg" aria-hidden="true"></span>
            </span>
          </p>
          <p class="feels"><span class="feels__label">Feels like</span> <span class="feels__val" data-feels>13°</span></p>
          <p class="range"><span>L <b data-low>11°</b></span><span>H <b data-high>17°</b></span></p>
          <p class="sky" data-sky>Light showers</p>
        </div>
      </div>

      <div class="hours" data-hours role="radiogroup" aria-label="Hour">
        <span class="hours__pill" data-pill aria-hidden="true"></span>
      </div>
    </article>
  </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.

31 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 “Weather thermometer” 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 warm white page, the Fairweather card for Lisbon, Saturday 28 November. On the left a hairline thermometer: the glass tube with its highlight, the bulb, the scale from 5 to 25 degrees with ticks and a number every five, and next to it two thin marks, H at the day’s high and L at its low. On entrance the ticks draw in from the top down, the column starts at the bottom, climbs on a spring to 15 degrees, overshoots by one and comes back, and the bulb swells a touch as it arrives; the ticks near the top of the column light up in the accent colour and grow longer. On the right the big degrees roll digit by digit, with «Feels like», the low and high and the sky below. At the bottom the row of hours: moving over it with the pointer, a finger or the arrow keys the pale pill slides under the hour, the column goes to its temperature, the degrees roll, «Feels like» and the sky change with a slide, and the column’s colour warms towards the high and cools towards the low. When nobody touches, the card moves to the next hour by itself.

How it works

The scale

The thermometer is an SVG with a fixed viewBox, so it sizes itself. One function turns degrees into height: SCALE_MAX at the top of the tube, SCALE_MIN just above the bulb. Ticks and numbers are created in a loop, one tick per degree, longer every five.

The spring

The column is not a tween: it is a value in degrees that a hand-written damped spring pulls towards the chosen temperature, in the GSAP ticker and with the real time between frames. STIFFNESS says how hard it pulls, DAMPING how fast it calms down: at 0.62 a ten-degree climb overshoots by about one and comes back.

The column in the glass

The column and the filled bulb sit inside a clipPath made of the tube and the bulb, so the top stays round and the column never leaves the glass. They are drawn on the same axis as the tube, x = 38, so they stay centred in every state.

The digits

Each digit is a column of ten numbers in a window 1 em tall: when the rounded value changes, the column slides to −10% per digit with back.out. On the way up the spring passes every number, so the digits roll by themselves.

The colour

gsap.utils.interpolate mixes two tones of the same orange, the cool one and the warm one, according to where the value sits between the low and the high. The same goes for the ticks, which turn from grey to orange the closer they are to the top of the column.

Values to change

NameFileDefaultWhat it changes
STIFFNESSscript.js60How hard the spring pulls the column to its temperature.
DAMPINGscript.js0.62How quickly the column calms down: lower overshoots more, 1 never overshoots.
SCALE_MINscript.js5The coldest degree on the scale.
SCALE_MAXscript.js25The warmest degree on the scale.
TICK_GLOWscript.js1.6How many degrees around the top of the column the ticks light up.
ROLLscript.js0.42How long each digit takes to roll, in seconds.
AUTO_PILOTscript.js2.4After how many still seconds the card moves to the next hour by itself (0 never).
--accentstyle.css#e0592aThe single accent colour, in its warm tone.

Try them in the Playground

When to use it

In a weather app or site, on the page of a hotel or holiday home showing the local weather, in the panel of a smart home or a greenhouse: wherever a temperature should read at a glance and change through the hours.

On phones

The thermometer is sized on the height (vh) and the big degrees on width and height together, so the card fits the box. The row of hours is tapped and dragged with a finger: same spring, same digits.

With reduced motion

No spring and no rolling: the column is already at its temperature, the digits change at once, «Feels like» and the sky crossfade and the card fades in.

Pitfalls

  • The column’s round top comes from the clipPath, not the rectangle’s radius: a rect with rx that gets shorter than 2 rx deforms.
  • The time between two frames is capped at a thirtieth of a second: after a tab in the background the spring would blow up.
  • The digits sit in a 1 em window with hidden overflow and tabular figures, so the number never changes width as it rolls and stays centred.
  • The hour pill is measured on the button’s offsetLeft and offsetWidth and measured again on resize.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0, JetBrains Mono (font variabile) 5.3.0.

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

Testing

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