# Wave volume

A volume slider whose track is the sound.

Also called: volume slider, volume control.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: A slider whose track is the sound. Drag down and the speaker loses its waves; fling to the top and the thumb squashes while the peaks hit the ceiling and flash. Preview: https://chatcn.dev/preview/wave-volume-demo

Left of the thumb the bars dance to what is playing; right of it they rest at their shape. The thumb squashes and stretches with how fast you drag it, the speaker loses its waves as you go quiet, and the number rolls. Fling it to the top and the peaks that hit the ceiling flash hot under a clip line, then calm down. Give it an analyser and the bars follow the real audio, like the voice an agent is speaking.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/wave-volume
```

## Usage

```tsx
import { WaveVolume } from "@/components/ui/chatcn/pro/wave-volume"

<WaveVolume value={volume} onValueChange={setVolume} analyser={voiceAnalyser} />
```

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `value` / `defaultValue` / `onValueChange` | `number` | 0 to 1 |
| `playing` | `boolean` | Default true |
| `analyser` | `AnalyserNode` | Real audio for the bars |
| `label` | `ReactNode` | Default Volume |

## Keyboard

| Key | Action |
| --- | --- |
| `Arrow keys` | 2 percent, 10 with `Shift` |
| `Home` / `End` | Silent or full |

## Accessibility

- A slider with its value as a percentage.

## Motion

- The thumb squash rides a spring from drag speed; the clip flash decays over about a second. Reduced motion: the thumb jumps and the bars hold still.

Source: https://chatcn.dev/docs/components/wave-volume