# Scene mixer

> 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.

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.

## Install

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

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

- npm: none
- Hairline UI components it needs (the CLI installs them too): `number-roll`, `text-morph`
- Docs and live preview: https://hairlineui.com/ui/scene-mixer
- Registry item (source): https://hairlineui.com/r/scene-mixer.json

## Usage

```tsx
import { SceneMixer } from "@/components/scene-mixer";

<SceneMixer
  title="Living room"
  channels={channels}
  onChannelChange={setLevel}
  scenes={scenes}
  scene={scene}
  onSceneChange={applyScene}
/>
```

## A room’s lights

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

```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

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `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` | `number` | `100` | The top of every level. |
| `unit` | `string` | `"%"` | Set after each figure. |

## 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.

## What it handles

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.

- **Levels by hand**: Drag a track or step it with the arrow keys; Shift steps by ten.
- **Scenes in one press**: The pill names the next scene and sets it.
- **See what it set**: Each level glides to its place and its figure rolls there.
- **Lit scenes**: A scene with a palette colours the tracks and lights the rim.
- **Custom**: Leave out scene once the levels no longer match one.
- **Screen readers**: Each level is a real slider with its value.

## Replaces

slider group, preset picker, scene selector, mixer panel, light scene control

## Where it fits

- **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.

## Notes

- 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.

License: MIT (https://hairlineui.com/license#components)
