Skip to content
animorio
IT
All components

Humidity slider

Sliders, Physics, HoverCanvas, GSAPMediumCompressed weight: Demo 8.8 KBGSAP 28 KBFreeDownload the zip

The bedroom humidifier card of a smart home app, dark on black, like a Dribbble shot: the ruler under the big number is the slider. Dragging it the thumb follows on a spring, the nearby ticks rise as if under a lens, the digits roll, the word goes from Dry air to Comfortable to Too damp, and behind the words a mist drawn on canvas thickens or thins with the value, from a few wisps to a soft bank of fog. Letting go, the thumb snaps to the whole number and the humidifier answers with a puff of mist from the bottom of the card.

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>
<!--
  "Humidity slider" 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 humidity slider with the mist that thickens</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 bedroom humidifier card of a premium smart home app. Behind the words a canvas draws the mist the
         humidifier would make: thin at 30%, a soft bank of fog at 70%. The ruler under the number is the slider:
         the ticks near the thumb rise like a magnifier, the thumb follows the finger on a spring -->
    <article class="humid" data-card aria-label="Bedroom humidifier">
      <canvas class="humid__mist" data-mist aria-hidden="true"></canvas>
      <span class="humid__sheen" data-sheen aria-hidden="true"></span>

      <header class="humid__head">
        <span class="humid__icon" aria-hidden="true">
          <svg viewBox="0 0 20 20"><path d="M10 2.6c2.9 3.4 5.2 6.3 5.2 9.1a5.2 5.2 0 0 1-10.4 0c0-2.8 2.3-5.7 5.2-9.1z"/><path class="humid__icon-wave" d="M7.4 12.4c.9.7 1.7.7 2.6 0s1.7-.7 2.6 0"/></svg>
        </span>
        <span class="humid__who">
          <span class="humid__room">Bedroom</span>
          <span class="humid__device">Brume Mist One</span>
        </span>
        <span class="humid__chip">
          <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M10.6 2.4a5.8 5.8 0 1 0 3 9.6 5 5 0 0 1-3-9.6z"/></svg>
          Night
        </span>
      </header>

      <div class="humid__read">
        <p class="humid__value" aria-hidden="true">
          <span class="humid__digits" data-digits></span><span class="humid__pct">%</span>
        </p>
        <div class="humid__side">
          <span class="humid__state" data-state>Comfortable</span>
          <span class="humid__now">Room now <b data-room>36%</b></span>
        </div>
      </div>

      <div class="humid__slider" data-slider role="slider" tabindex="0" aria-label="Target humidity"
           aria-valuemin="30" aria-valuemax="70" aria-valuenow="48" aria-valuetext="48 percent, comfortable">
        <span class="humid__band" data-band aria-hidden="true"><span>Comfort</span></span>
        <span class="humid__ticks" data-ticks aria-hidden="true"></span>
        <span class="humid__thumb" data-thumb aria-hidden="true"><span class="humid__thumb-core"></span></span>
        <span class="humid__ends" aria-hidden="true"><span>30</span><span>70</span></span>
      </div>

      <footer class="humid__foot">
        <span class="humid__stat"><span class="humid__label">Reaches target</span><b data-eta>in 13 min</b></span>
        <span class="humid__stat"><span class="humid__label">Tank lasts</span><b data-tank>7 h 50 m</b></span>
      </footer>
    </article>
    <p class="sr" aria-live="polite" data-live></p>
  </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

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 “Humidity slider” 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 black a dark card rises slowly, with very round corners and a one pixel edge that catches the light: at the top the droplet icon in a glass tile, ‘Bedroom’ and ‘Brume Mist One’, on the right the ‘Night’ pill with its moon. Below, the big number ‘48 %’ and beside it, in teal, ‘Comfortable’ with ‘Room now 36%’. Lower down a ruler of thin ticks from 30 to 70, with the comfort range lit between 40 and 60, and a glowing vertical thumb; at the bottom two figures, how long until the chosen humidity is reached and how long the tank lasts. Behind the words a faint mist rises, soft ovals lifting from the bottom and fading. The thumb is taken: it widens a little, the nearby ticks rise higher, and it slides down to 34: the word turns amber, ‘Dry air’, and the mist thins to a few wisps. Then it climbs to 66, ‘Too damp’, and the mist becomes a bank covering half the card; it comes back to 48, is let go with a small elastic bounce and the humidifier answers with a puff of mist from the bottom. The digits roll at every number, the figures at the bottom change with it, the card's edge lights up under the thumb. With a finger or the mouse the ruler really drags, pulls like a rubber band past the ends, and from the keyboard it moves with the arrow keys.

How it works

A ruler that is the slider

Forty-one ticks, one for every point from 30 to 70, 7 pixels tall and 13 every five, tinted teal inside the comfort range. Their container has role slider, aria-valuenow and aria-valuetext, is taken with the pointer (setPointerCapture) and moves with the arrows, Page Up and Down, Home and End.

The thumb on a spring

The thumb's value chases the finger's with a spring integrated by hand, stiffness 260 and damping 21, in two steps per frame with the time step capped at 1/30 of a second: it passes the mark by a breath and settles. Past the ends the finger counts for only 18%, like a rubber band; on release the goal rounds to the whole number.

Ticks as if under a lens

Every frame each tick grows by a gaussian of its distance from the thumb (sigma 2.3 points), stronger while it is held; scaleY and opacity are written only when they really change, so at rest nothing is touched.

The mist on canvas

A single radial gradient sprite, drawn once, is stamped 44 times squashed into ovals, in lighter mode, with an alpha that rises and falls with the sine of each wisp's life. The density follows the value with an exponential lag; the height the wisps rise to and the band at the bottom grow with it, and the puff after a release speeds up the rise and adds light.

Digits, word and figures

The two digits are columns of ten sliding with yPercent and a back.out; the word, the card's tone (a CSS variable) and the two figures at the bottom change when the whole number changes. The light on the edge is a radial gradient masked onto the edge's pixel that follows the pointer, or the thumb when the card runs on its own.

Values to change

NameFileDefaultWhat it changes
TARGETscript.js48The target humidity the card starts and rests on, from 30 to 70.
ROOMscript.js36The humidity the room has now, in percent.
COMFORT_LOWscript.js40Where the comfortable range starts.
COMFORT_HIGHscript.js60Where the comfortable range ends.
MISTscript.js1How thick the mist gets: 0 none, 2 twice as dense.
MAGNIFYscript.js13How many pixels the ticks near the thumb rise.
STIFFNESSscript.js260The spring pulling the thumb to the finger: higher is quicker.
DAMPINGscript.js21Lower lets the thumb pass the mark and come back.
SPEEDscript.js12 = the walk on its own twice as fast, 0.5 = half.
LOOPscript.jstrueRepeats the walk on its own.

Try them in the Playground

When to use it

In a smart home app or a connected appliance's app (humidifier, purifier, air conditioner), in the wellness panel of a hotel room, in a sleep app: anywhere a value is chosen on a scale and its meaning should show at once.

On phones

The same card with adapted sizes: at most 86% of the screen wide, gaps and number sized on the height too (clamp with vh), the ticks rearrange at every resize and the mist canvas is redrawn as big as the card. With a finger the ruler drags without scrolling the page.

With reduced motion

No spring, no following lens, no rising mist: the thumb moves straight to the value, the digits change without rolling and the mist is a still image that thickens or thins with a fade; on its own the card shows 34, 66 and 48 one after the other.

Pitfalls

  • The mist canvas is measured with offsetWidth, not getBoundingClientRect: while the card enters at a scale of 0.985 the rectangle is smaller and the mist stayed narrow.
  • Rewriting 41 transforms every frame even at rest weighs on a phone: each tick remembers its last height and is touched only when it changes.
  • On release the goal is rounded, not the value: rounding the value made the thumb jump without its spring.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 8.8 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