Skip to content
Browse documentation

A few levels and the scenes that set them: press a scene and a soft veil of light drifts across the card while every level glides to its place.

Used forLightingAudioNotificationsClimate

Install with the shadcn CLI

$ npx shadcn@latest add https://hairlineui.com/r/scene-mixer.json

Registered the namespace? Then it’s shadcn add @hairline/scene-mixer. Set it up

Templates

Need the whole page?

61 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 6 are free.

All 61 templates

Where it’s used

  • Lighting

    A room’s lights and its scenes: Bright, Night glow, Reading.

  • Audio

    A few buses or stems and the mixes that set them.

  • Notifications

    Levels per channel and profiles like Focus or Travel.

  • Climate

    Fan, heat and humidity, with presets for night and away.

What it handles for you

Sliders that snap to a preset all at once don’t show what the preset did, and a list of presets elsewhere loses the link to the levels.

Instead of wiring upslider grouppreset pickerscene selectormixer panellight scene control
  1. Levels by hand

    Drag a track or step it with the arrow keys; Shift steps by ten.

  2. Scenes in one press

    The pill names the next scene and sets it.

  3. See what it set

    Each level glides to its place and its figure rolls there.

  4. Lit scenes

    A scene with a palette colours the tracks and lights the rim.

  5. Custom

    Leave out scene once the levels no longer match one.

  6. Screen readers

    Each level is a real slider with its value.

Overview

Lights in a room, buses in a mix, notification levels: several levels that usually move together, as scenes. Most apps snap every slider to its new place at once, and you can’t tell what a scene did. Scene mixer keeps each level as a fine track you drag or step with the keys, and names the next scene in a pill. Press it and a wide, soft veil of light drifts across the card (no hard band), the scene changes under it, and every level glides to its new place while its figure rolls there, so you see exactly what the scene set. A scene with a palette colours the tracks and keeps the card’s rim lit while it’s set; move a level by hand and the scene becomes Custom.

States

drag
The thumb follows the pointer with no transition and grows to 118%; the figure shows plain digits while held.
scene
A veil drifts across over 1.36s; at 36% onSceneChange runs and each level glides over 640ms (ease-out) while its figure rolls over 720ms.
lit
A scene with a palette fills the tracks with its colour and lights the rim.
reduced motion
No veil; levels move in place.

Usage

usage.tsx
import { SceneMixer } from "@/components/scene-mixer";<SceneMixer  title="Living room"  channels={channels}  onChannelChange={setLevel}  scenes={scenes}  scene={scene}  onSceneChange={applyScene}/>

Works with

A room’s lights

Hold the levels and the scene name in your state; setting a scene sets both.

example.tsx
"use client";import { useState } from "react";import { SceneMixer, type MixerScene } from "@/components/scene-mixer";const scenes: MixerScene[] = [  { name: "Bright", values: { ceiling: 100, lamp: 80 } },  { name: "Night glow", values: { ceiling: 12, lamp: 0 }, palette: "dusk" },];export function LivingRoom() {  const [scene, setScene] = useState<string | undefined>("Bright");  const [levels, setLevels] = useState(scenes[0].values);  return (    <SceneMixer      title="Living room"      channels={[{ id: "ceiling", label: "Ceiling", value: levels.ceiling }, { id: "lamp", label: "Floor lamp", value: levels.lamp }]}      onChannelChange={(id, value) => {        setLevels((l) => ({ ...l, [id]: value }));        setScene(undefined);      }}      scenes={scenes}      scene={scene}      onSceneChange={(name) => {        const s = scenes.find((x) => x.name === name)!;        setScene(name);        setLevels(s.values);        fetch("/api/rooms/living/scene", { method: "PUT", body: JSON.stringify({ name }) });      }}    />  );}

Props

title
string
The card’s heading.
subtitle
string
A line under it.
icon
ReactNode
A badge beside the heading.
channels
{ id: string; label: string; value: number }[]
The levels.
onChannelChange
(id: string, value: number) => void
A level moved by hand.
scenes
{ name: string; values: Record<string, number>; palette?: … }[]
The scenes, in the order the pill offers them.
scene
string
The scene that’s set; leave it out for Custom.
onSceneChange
(name: string) => void
Called under the veil with the scene to set: set the scene and its levels.
max= 100
number
The top of every level.
unit= "%"
string
Set after each figure.

Accessibility and motion

  • Tracks move with transforms only (a scaled fill and a translated thumb layer), so a glide never relays out the card.
  • Dragging turns the glide off for that track and shows plain digits; the figures roll only when a scene moves them.
  • The light is a 2D canvas over the card, drawn only while the veil crosses.
  • Reduced motion drops the veil and the glide.

Requirements

React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

The CLI also installs Number roll, Text morph.

Source

"use client";import * as React from "react";import { LightSurface, clamp, resolvePalette, useLightReducedMotion, type LightPalette, type LightPaletteName, type LightSurfaceHandle } from "./light-surface";import { NumberRoll } from "./number-roll";import { TextMorph } from "./text-morph";import { INTERACTION_FOCUS, INTERACTION_PRESS } from "./ui-interaction-motion";/* ───────────────────────────────────────────────────────── * SCENE MIXER: a few levels and the scenes that set them * *   levels   each channel is a fine track with a thumb you *            drag, or step with the arrow keys *   scene    the pill names the next scene; press it and a *            soft veil of light drifts across the card, the *            scene changes under it, and every level glides to *            its new place while the figures roll there *   lit      a scene with a palette colours the tracks and *            keeps the card's rim lit while it's set * * Reduced motion: no veil; levels move in place. * ───────────────────────────────────────────────────────── */export interface MixerChannel {  id: string;  label: string;  value: number;}export interface MixerScene {  name: string;  /** Levels by channel id. */  values: Record<string, number>;  /** Colours the tracks and lights the rim while this scene is set. */  palette?: LightPaletteName | LightPalette;}export interface SceneMixerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {  title: string;  subtitle?: string;  icon?: React.ReactNode;  channels: MixerChannel[];  /** A level moved by hand. */  onChannelChange: (id: string, value: number) => void;  scenes?: MixerScene[];  /** The scene that's set, by name; leave it out once the levels no longer match one. */  scene?: string;  /** Called under the veil with the scene to set: set the scene and its levels here. */  onSceneChange?: (name: string) => void;  max?: number;  unit?: string;}function Level({  channel,  max,  unit,  fill,  glide,  onChange,}: {  channel: MixerChannel;  max: number;  unit: string;  fill: string;  glide: boolean;  onChange: (value: number) => void;}) {  const track = React.useRef<HTMLDivElement>(null);  const [dragging, setDragging] = React.useState(false);  const k = clamp(channel.value / max, 0, 1);  const move = glide && !dragging ? "transform 640ms cubic-bezier(0.16,1,0.3,1)" : "none";  const fromPointer = (clientX: number) => {    const r = track.current?.getBoundingClientRect();    if (r) onChange(clamp(Math.round(((clientX - r.left) / r.width) * max), 0, max));  };  return (    <div className="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 @[24rem]:grid-cols-[minmax(0,6.5rem)_minmax(0,1fr)_3rem]">      <span className="truncate text-[13px] text-muted-foreground">{channel.label}</span>      <div        ref={track}        role="slider"        tabIndex={0}        aria-label={channel.label}        aria-valuemin={0}        aria-valuemax={max}        aria-valuenow={channel.value}        aria-valuetext={`${channel.value}${unit}`}        onPointerDown={(e) => {          e.currentTarget.setPointerCapture(e.pointerId);          setDragging(true);          fromPointer(e.clientX);        }}        onPointerMove={(e) => dragging && fromPointer(e.clientX)}        onPointerUp={() => setDragging(false)}        onPointerCancel={() => setDragging(false)}        onKeyDown={(e) => {          const by = e.shiftKey ? 10 : 1;          const keys: Record<string, number> = { ArrowRight: by, ArrowUp: by, ArrowLeft: -by, ArrowDown: -by, PageUp: 10, PageDown: -10 };          if (e.key in keys) onChange(clamp(channel.value + keys[e.key], 0, max));          else if (e.key === "Home") onChange(0);          else if (e.key === "End") onChange(max);          else return;          e.preventDefault();        }}        className={`relative order-3 col-span-2 flex h-6 cursor-pointer touch-none select-none items-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring/50 @[24rem]:order-2 @[24rem]:col-span-1 ${dragging ? "cursor-grabbing" : ""}`}      >        <span className="relative h-[3px] w-full overflow-clip rounded-full bg-[color-mix(in_oklab,var(--foreground)_13%,transparent)]">          <span className="absolute inset-0 origin-left rounded-full" style={{ background: fill, transform: `scaleX(${k})`, transition: move, willChange: "transform" }} />        </span>        <span aria-hidden className="pointer-events-none absolute inset-0" style={{ transform: `translateX(${k * 100}%)`, transition: move }}>          <span            className={`absolute top-1/2 size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground shadow-[0_0_0_2px_var(--card)] transition-[scale] duration-150 ${dragging ? "scale-[1.18]" : ""}`}          />        </span>      </div>      <span className="order-2 text-right text-[12.5px] font-medium tabular-nums text-foreground @[24rem]:order-3">        {dragging ? (          <span>            {channel.value}            {unit}          </span>        ) : (          <NumberRoll value={channel.value} suffix={unit} duration={720} />        )}      </span>    </div>  );}export function SceneMixer({  title,  subtitle,  icon,  channels,  onChannelChange,  scenes = [],  scene,  onSceneChange,  max = 100,  unit = "%",  className = "",  ...props}: SceneMixerProps) {  const surface = React.useRef<LightSurfaceHandle>(null);  const reduced = useLightReducedMotion();  const current = scenes.find((s) => s.name === scene);  const index = current ? scenes.indexOf(current) : -1;  const next = scenes.length ? scenes[(index + 1) % scenes.length] : undefined;  const pal = current?.palette ? resolvePalette(current.palette) : null;  const fill = pal ? `linear-gradient(90deg, ${pal.ink}, color-mix(in oklab, ${pal.ink} 45%, white))` : "var(--foreground)";  const busy = React.useRef(false);  const apply = () => {    if (!next || !onSceneChange || busy.current) return;    const s = surface.current;    if (!s || reduced) return onSceneChange(next.name);    busy.current = true;    s.wave({      direction: "diagonal",      palette: next.palette ?? "dusk",      onMidpoint: () => onSceneChange(next.name),      onComplete: () => {        busy.current = false;      },    });  };  return (    <LightSurface ref={surface} palette={current?.palette ?? "dusk"} direction="diagonal" lit={!!pal} className={`rounded-[30px] ${className}`} {...props}>      <div className="@container px-6 pb-6 pt-5">        <div className="flex items-center justify-between gap-3">          <div className="flex min-w-0 items-center gap-3">            {icon && <span className="grid size-10 shrink-0 place-items-center rounded-full bg-muted text-foreground">{icon}</span>}            <div className="min-w-0">              <div className="truncate text-[14px] font-medium text-foreground">{title}</div>              {subtitle && <div className="truncate text-[12.5px] text-muted-foreground">{subtitle}</div>}            </div>          </div>          {next && onSceneChange && (            <button              type="button"              onClick={apply}              aria-label={`Set scene: ${next.name}`}              className={`h-9 shrink-0 cursor-pointer whitespace-nowrap rounded-full bg-muted px-4 text-[12.5px] font-medium text-foreground hover:bg-accent ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}            >              <TextMorph>{next.name}</TextMorph>            </button>          )}        </div>        <div className="mt-5 text-[20px] font-medium tracking-[-0.02em] text-foreground">{scene ?? "Custom"}</div>        <div className="mt-3 space-y-2 @[24rem]:space-y-1.5">          {channels.map((c) => (            <Level key={c.id} channel={c} max={max} unit={unit} fill={fill} glide={!reduced} onChange={(v) => onChannelChange(c.id, v)} />          ))}        </div>      </div>    </LightSurface>  );}

Registry item: /r/scene-mixer.json