Skip to content
animorio
IT
All components

Home scene selector

Pickers, Hover, Transitions, PhysicsGSAP, CSS onlyMediumCompressed weight: Demo 7.9 KBGSAP 28 KBFreeDownload the zip

The living room scenes widget of an invented smart home app, Halvo Home: Morning, Focus, Movie and Night under a frosted glass lens. Tap a scene or drag the lens with a finger: it runs on a real spring, stretches with its speed and a light the colour of the scene rides under the glass. The room light changes colour temperature, the Kelvin reading and the brightness count to the new values, the marker slides along the warm to cool scale and the scene icon comes alive.

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>
<!--
  "Home scene selector" 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 smart home lights scene selector with the glass lens and the light that changes temperature</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 scene widget of an invented smart home app: four scenes under a frosted glass lens; the light of the
         room changes colour temperature, the Kelvin reading and the brightness count to the new scene -->
    <section class="scenes" data-scenes aria-labelledby="sc-room">
      <span class="scenes__light" aria-hidden="true"></span>
      <span class="scenes__wash" aria-hidden="true" data-wash></span>
      <span class="scenes__edge" aria-hidden="true"></span>

      <header class="scenes__head">
        <div class="scenes__now">
          <span class="scenes__room" id="sc-room">Living room</span>
          <span class="scenes__name" aria-live="polite"><span class="scenes__word" data-word>Morning</span><span class="scenes__word" data-word aria-hidden="true"></span></span>
          <span class="scenes__meta">4 lights <span class="scenes__sep">·</span> <span class="scenes__num" data-bright>70</span>%</span>
        </div>
        <div class="warmth" aria-label="Colour temperature">
          <span class="warmth__value"><span class="scenes__num" data-kelvin>3000</span> K</span>
          <span class="warmth__bar" aria-hidden="true"><span class="warmth__mark" data-mark></span></span>
          <span class="warmth__ends" aria-hidden="true"><span>Warm</span><span>Cool</span></span>
        </div>
      </header>

      <div class="track" role="radiogroup" aria-label="Scene" data-track>
        <span class="track__glow" aria-hidden="true" data-glow></span>
        <span class="lens" aria-hidden="true" data-lens><span class="lens__body" data-lens-body><span class="lens__shine"></span></span></span>
        <button class="seg" type="button" role="radio" aria-checked="true" data-seg>
          <svg class="seg__icon" viewBox="0 0 24 24" aria-hidden="true"><g class="ic ic--morning"><path class="ic__ray" d="M12 4.2v1.6M6.3 6.6l1.1 1.1M17.7 6.6l-1.1 1.1M3.6 12.2h1.6M18.8 12.2h1.6"/><path class="ic__sun" d="M7.6 15.4a4.4 4.4 0 0 1 8.8 0"/><path d="M3.4 15.4h17.2M7 18.6h10"/></g></svg>
          <span class="seg__label">Morning</span>
        </button>
        <button class="seg" type="button" role="radio" aria-checked="false" tabindex="-1" data-seg>
          <svg class="seg__icon" viewBox="0 0 24 24" aria-hidden="true"><g class="ic ic--focus"><circle class="ic__ring" cx="12" cy="12" r="7.4" stroke-dasharray="3.2 2.6"/><circle class="ic__core" cx="12" cy="12" r="2.6"/></g></svg>
          <span class="seg__label">Focus</span>
        </button>
        <button class="seg" type="button" role="radio" aria-checked="false" tabindex="-1" data-seg>
          <svg class="seg__icon" viewBox="0 0 24 24" aria-hidden="true"><g class="ic ic--movie"><rect x="3.4" y="5.4" width="17.2" height="11.6" rx="2.6"/><path d="M9 20h6"/><path class="ic__play" d="M10.6 8.9l3.9 2.3-3.9 2.3z"/></g></svg>
          <span class="seg__label">Movie</span>
        </button>
        <button class="seg" type="button" role="radio" aria-checked="false" tabindex="-1" data-seg>
          <svg class="seg__icon" viewBox="0 0 24 24" aria-hidden="true"><g class="ic ic--night"><path class="ic__moon" d="M17.6 14.6A6.8 6.8 0 0 1 9.4 6.4a6.8 6.8 0 1 0 8.2 8.2z"/><path class="ic__star" d="M17 4.2l.6 1.6 1.6.6-1.6.6-.6 1.6-.6-1.6-1.6-.6 1.6-.6z"/></g></svg>
          <span class="seg__label">Night</span>
        </button>
      </div>
    </section>
    <svg class="pointer" viewBox="0 0 24 24" aria-hidden="true" data-pointer><path d="M5 3.5 18.5 12 12.4 13.6 9.4 19.6z"/></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.

32 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 “Home scene selector” 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

A white card with soft layered shadows and a one pixel edge that takes the colour of the light. From the top right corner falls the room light, a halo the colour of the scene that breathes slowly. Below, four scenes in a very light grey track, and over the chosen one a frosted glass lens. Tap another scene and the lens runs over on a real spring, stretching and squashing a little with its speed, a highlight sliding inside, settling with one pixel of overshoot; under the glass a blurred light the colour of the scene travels with it. Meanwhile the room halo changes colour and dims with the brightness, a wave of light leaves the lens, the scene name leaves and the new one arrives wide on the wdth axis and narrows, the Kelvin and the percentage count, the marker slides along the Warm and Cool scale with a bounce and the icon comes alive: the sun rises and opens its rays, the Focus ring turns and tightens, the Movie triangle snaps in, the moon rocks and the star lights up. Pressed, the lens sinks a little; dragged, it changes scene as it passes.

How it works

The lens on a real spring

The lens position is a spring integrated every frame with requestAnimationFrame: velocity grows with (target minus position) times STIFFNESS and drops with DAMPING, with the time step capped at 1/30 of a second. With 420 and 30 the spring is a little under critical damping, so it overshoots by one pixel and comes back. When velocity and distance are nearly zero the loop stops and draws nothing more.

The glass that stretches

The outer lens moves with translateX, the glass inside deforms: scaleX grows with speed times STRETCH (up to 24%) and scaleY drops by a little less than half of that, so the volume seems the same. The highlight inside the glass is a CSS variable that moves against the motion. Pressed, the lens sinks to 95% and comes back with elastic.out.

The light under the glass

Behind the lens an ellipse the colour of the scene, blurred by 14 pixels, follows it; the glass has backdrop-filter with blur and saturate, so the colour shows through. The room halo, the edge and the lens shadow all use the --tint variable, which GSAP moves from one colour to the next; --glow dims the halo with the brightness of the scene.

Dragging and changing scene on the way

On the track a pointerdown captures the pointer; past 4 pixels of movement it becomes a drag and the spring target follows the finger with a higher stiffness. Every frame the scene is the one closest to the lens, so it changes as the lens passes. On release the lens goes to the nearest scene allowing for its speed, like a throw.

Numbers, name and icons

Kelvin (rounded to tens) and the percentage count with a tween on an object and power3.out; the marker moves by left in percent on the 1800 to 6500 K scale with back.out. The name has two lines that take turns: the old one leaves narrow on the wdth axis, the new one comes in at 122% and narrows to 100%. Each icon has its own small SVG timeline with svgOrigin.

Values to change

NameFileDefaultWhat it changes
STIFFNESSscript.js420Stiffness of the lens spring: higher snaps faster.
DAMPINGscript.js30Friction of the spring: lower overshoots and wobbles more.
STRETCHscript.js0.0005How much the glass stretches with speed (0 none).
LIGHT_TIMEscript.js0.9Seconds for the room light to change colour.
COUNT_TIMEscript.js0.8Seconds for Kelvin and brightness to count.
SPEEDscript.js1Pilot speed.
LOOPscript.jstrueThe pilot starts over.

Try them in the Playground

When to use it

In the app or dashboard of a smart home, a lighting system, a thermostat or a hotel room with lights to choose: wherever you switch from one set of settings to another with a tap. The same lens works for any segmented control with three to five options.

On phones

The same animation with adapted sizes: the card is up to 94% of the screen wide, margins and the name also follow the window height. A finger taps a scene or drags the lens, and vertical page scrolling stays free.

With reduced motion

Nothing moves: the lens is on the chosen scene at once, with no spring or stretch, the light colours change with a fade, numbers change without counting, the name cross-fades and the icons stay still; the pilot pointer is hidden.

Pitfalls

  • The lens both moves and stretches: on one element translateX and scale combined around the wrong point and the stretched lens left the track. The outer element moves, the inner one deforms around its centre.
  • The button click and the drag on the track both fired and the scene changed twice; now the track handles the pointer and the button click only counts from the keyboard (detail 0).

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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