Skip to content
animorio
IT
All components

Air quality widget

Weather, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 11 KBGSAP 28 KBFreeDownload the zip

The air quality widget of a weather app, in frosted glass on near black, with two soft lights behind the glass that take the colour of the air: a four part arc with the index rising, digits that roll, a one pixel edge and a light that follow the pointer. Refresh it and the digits roll to the new value, the arc reaches it on a spring and the light behind moves from mint to amber; tap it and the card flips on a real spring, with a sheen crossing the glass, and its back shows the pollutants with bars that fill.

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>
<!--
  "Air quality widget" 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 glass air quality widget that flips on a spring</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>
    <!-- two soft lights behind the glass: they take the colour of the air -->
    <span class="orb orb--a" data-orb aria-hidden="true"></span>
    <span class="orb orb--b" data-orb aria-hidden="true"></span>

    <div class="widget" data-widget>
      <span class="widget__shadow" data-shadow aria-hidden="true"></span>
      <!-- the glass card: one element turns (front and back swap at 90 degrees), the light and the 1px edge follow the pointer -->
      <article class="card" data-card aria-label="Air quality">
        <span class="card__grain" aria-hidden="true"></span>
        <span class="card__spot" aria-hidden="true"></span>
        <span class="card__sheen" data-sheen aria-hidden="true"></span>

        <section class="face face--front" data-front>
          <header class="head">
            <div class="head__words">
              <span class="head__kicker">
                <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 6h7.5a2.2 2.2 0 1 0-2.2-2.2M2 9.5h10a2.2 2.2 0 1 1-2.2 2.2M2 13h4.5"/></svg>
                Air quality
              </span>
              <span class="head__place" data-place>Harbour District</span>
            </div>
            <span class="chip">US AQI</span>
          </header>

          <div class="gauge">
            <svg class="gauge__svg" viewBox="0 0 220 162" aria-hidden="true">
              <defs>
                <filter id="soft" x="-20%" y="-20%" width="140%" height="140%"><feGaussianBlur stdDeviation="4"/></filter>
              </defs>
              <g data-segs></g>
              <path class="gauge__glow" data-glow pathLength="1" d=""/>
              <path class="gauge__fill" data-fill pathLength="1" d=""/>
              <g data-tick><line class="gauge__tick" x1="110" y1="7" x2="110" y2="25"/></g>
              <text class="gauge__end" x="37" y="160" text-anchor="middle">0</text>
              <text class="gauge__end" x="183" y="160" text-anchor="middle">200</text>
            </svg>
            <div class="gauge__read">
              <span class="num" data-num aria-hidden="true"></span>
              <span class="level"><span class="roll" data-level>Good</span></span>
            </div>
          </div>

          <p class="insight"><span class="roll" data-insight>Clear air for a run along the water.</span></p>

          <footer class="foot">
            <span class="foot__time"><span class="roll" data-updated>Updated 2 min ago</span></span>
            <button class="icon-btn" type="button" data-refresh aria-label="Refresh the reading">
              <span class="btn-face" data-face>
                <svg viewBox="0 0 20 20" aria-hidden="true" data-spin><path d="M15.6 7.4A6 6 0 0 0 4.3 8.2M4.4 12.6a6 6 0 0 0 11.3-.8"/><path d="M15.9 3.6v3.9h-3.9M4.1 16.4v-3.9h3.9"/></svg>
              </span>
            </button>
            <button class="pill-btn" type="button" data-flip aria-label="Show the pollutants">
              <span class="btn-face" data-face>Details<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6.5 4l4 4-4 4"/></svg></span>
            </button>
          </footer>
        </section>

        <section class="face face--back" data-back aria-hidden="true" inert>
          <header class="head">
            <div class="head__words">
              <span class="head__kicker">Pollutants</span>
              <span class="head__place">Right now</span>
            </div>
            <span class="chip">µg/m³</span>
          </header>

          <ul class="rows" data-rows>
            <li class="row"><span class="row__name">PM2.5</span><span class="row__bar"><span class="row__fill" data-bar></span></span><span class="row__val" data-val>0</span></li>
            <li class="row"><span class="row__name">PM10</span><span class="row__bar"><span class="row__fill" data-bar></span></span><span class="row__val" data-val>0</span></li>
            <li class="row"><span class="row__name">O<sub>3</sub></span><span class="row__bar"><span class="row__fill" data-bar></span></span><span class="row__val" data-val>0</span></li>
            <li class="row"><span class="row__name">NO<sub>2</sub></span><span class="row__bar"><span class="row__fill" data-bar></span></span><span class="row__val" data-val>0</span></li>
          </ul>

          <div class="hours">
            <span class="hours__head"><span>Next 12 hours</span><span class="hours__peak" data-peak>Peak 48 at 1 pm</span></span>
            <span class="hours__bars" data-hours aria-hidden="true"></span>
            <span class="hours__axis" aria-hidden="true"><span>Now</span><span>6 pm</span><span>Midnight</span></span>
          </div>

          <footer class="foot foot--back">
            <span class="best">
              <span class="best__label">Best hours outside</span>
              <span class="best__time" data-best>All day</span>
            </span>
            <button class="pill-btn pill-btn--back" type="button" data-unflip aria-label="Back to the overview">
              <span class="btn-face" data-face><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M9.5 4l-4 4 4 4"/></svg>Overview</span>
            </button>
          </footer>
        </section>
      </article>
    </div>

    <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"/></svg>
    <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.

43 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 “Air quality widget” 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

In the middle, on a near black background, a frosted glass card: behind the glass two blurred lights drift slowly, one in the colour of the air and one blue, showing through the card. At the top Air quality with a small wind icon, the Harbour District neighbourhood and the US AQI pill. Below, a 240 degree arc split into four faint parts (green, amber, orange, pink) from 0 to 200, with the bright part rising to the index, a soft glow and a white tick; in the middle the big number with two rolling digits, below it Good in the colour of the air, a sentence (Clear air for a run along the water.) and at the bottom Updated 2 min ago, the round refresh button and the Details pill. The card tilts a few degrees towards the pointer, its one pixel edge lights up where the pointer passes and a soft light follows it on the glass. Pressing refresh spins the icon, the label rolls to Updating…, the digits roll to the new value, the arc reaches it with a small overshoot, the label becomes Moderate and the colour of the arc, the edge and the light behind the glass slides from mint to amber; the card takes a two pixel breath. Tapping the card or Details flips it on a real spring: it lifts a little, a sheen crosses the glass, the shadow below narrows when the card is edge on and the turn goes a few degrees past and comes back. On the back are PM2.5, PM10, O3 and NO2 with bars filling one after the other and numbers rising, below them Next 12 hours with twelve small columns growing from the left, each in the colour of its hour, and at the bottom Best hours outside and the Overview pill to go back. The autopilot pointer passes over the glass, refreshes, flips the card and flips it back.

How it works

The glass and the one pixel edge

The card has a backdrop-filter with blur over two blurred lights in the background, an almost transparent white gradient and a grain made with feTurbulence in an SVG background. The edge is a ::before with one pixel of padding and a mask that keeps only the frame (mask-composite: exclude): its background is a radial-gradient centred on --mx and --my, the pointer’s coordinates, so it lights up only where the light passes.

The flip on a real spring

The card’s angle follows a spring worked out every frame (force = -stiffness × distance - damping × velocity), in steps of 1/240 of a second. The target is 0 or 180: below 90 degrees you see the front, above it the back, turned by angle - 180 so it is not mirrored. Only one element turns, without preserve-3d, which is why the backdrop-filter keeps working during the flip.

Sheen, lift and shadow

Three things come from the sine of the angle: the card’s scale (up to +3.5% when edge on), the opacity and position of the band of light crossing the glass, and the width of the shadow below, which narrows halfway through the turn. All in the same hand written transform, together with the tilt towards the pointer, which has its own two springs.

The arc and the digits

The arc is a 240 degree SVG path with pathLength=1: the bright part is a stroke-dasharray GSAP takes to the value with back.out, and the white tick turns around the centre with the same value. The number is two reels of digits from 0 to 9, moved with yPercent under a mask that fades at top and bottom. The colour of the air is a CSS variable, --lvl, that GSAP slides on the arc, the edge, the bars and the light behind the glass all together.

Values to change

NameFileDefaultWhat it changes
STIFFNESSscript.js170The stiffness of the spring that flips the card: higher is quicker.
DAMPINGscript.js18The damping of the spring: lower makes the card go further past the half turn and come back.
TILTscript.js5How many degrees at most the card tilts towards the pointer.
BLURscript.js14How frosted the glass is, in pixels of blur.
GOOD_COLORscript.js#5be3b0The colour of good air: arc, edge, bars and the light behind the glass.
MODERATE_COLORscript.js#f6c35bThe colour of moderate air.
PLACEscript.jsHarbour DistrictThe neighbourhood written at the top.

Try them in the Playground

When to use it

On the home screen of a weather, health or running app, or in a smart home dashboard with an air purifier: a glance on the front (number, colour, one sentence to read) and the details on the back, without opening another page.

On phones

The card is sized on the window’s width and height and stays whole in the frame; tap it to flip it, refresh with the round button, and the light and the tilt follow your finger.

With reduced motion

No tilt and no turn: front and back swap with a fade, the digits change without rolling, the labels fade and the light stays still.

Pitfalls

  • With two faces in preserve-3d and backface-visibility the backdrop-filter stops blurring: the glass turns clear right during the flip. Only one flat element turns, and at 90 degrees the content swaps.
  • With saturate() next to the blur in the backdrop-filter, Chromium without a graphics card drew the glass in four tiles with visible seams right behind the number: the glass uses blur only, at 14 pixels, and the colour comes from the lights behind.
  • An opacity below 1 on a parent of the card makes that parent the backdrop-filter’s root, which then blurs nothing: the entrance fades the card itself, never its container.
  • The light’s position is worked out from the card’s centre and its width without the transform (offsetWidth for the demo’s scale): getBoundingClientRect alone gave a misplaced light with the card tilted or halfway through the turn.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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