Knob
A raised, turning cap ringed by tick marks that light up in colour and swell around the pointer, with an optional click as you turn it.
Installation
pnpm dlx shadcn@latest add @breeze/knobUsage
import { Knob } from "@/components/breeze/knob"<Knob label="Volume" defaultValue={50} />Drag up or right to turn it up, and down or left to turn it down. A full sweep is about 200px, and holding Shift makes it 10x finer. Arrow keys step through values (Shift for 10x), Home and End jump to the ends, and a double-click resets to defaultValue.
Anatomy
- Cap: the same surface as the rest of Breeze, with a gradient fill, a hairline edge and a soft drop shadow. It turns with the value, and its coloured notch points at it. It presses in slightly while you hold it.
- Ticks: the ticks up to the value light up in
color. The ones around the pointer swell outward like a lens, a little at rest, more on hover and most while you drag. - Readout: the value and label sit under the knob, so the cap never has to rotate text.
Bipolar
bipolar lights the ticks from the middle of the range out to the value, which suits pan, balance or offsets. The default value becomes the centre, and on a range around zero, positive values get a +.
<Knob label="Balance" min={-50} max={50} bipolar />Sound
Add sound and a soft click plays each time the value crosses a tick. Fewer ticks gives you chunkier detents. The click is generated with WebAudio, so there's no audio file to ship, and it only starts after the first interaction, as browsers require.
<Knob label="Tone" min={0} max={10} step={0.1} ticks={11} sound />Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | Text under the value, also the accessible name | |
value | number | Controlled value | |
defaultValue | number | min (centre if bipolar) | Starting value when uncontrolled, and the double-click reset target |
onChange | (value: number) => void | Called with each new value | |
min | number | 0 | Lowest value |
max | number | 100 | Highest value |
step | number | 1 | Value increment |
color | string | "var(--brand)" | Lit ticks and the pointer notch, any CSS colour or var() |
size | number | 88 | Diameter in px |
ticks | number | 36 | Tick marks around the ring |
bipolar | boolean | false | Light the ticks from the centre of the range |
sound | boolean | false | Click as the value crosses each tick |
volume | number | 0.35 | Click volume, 0 to 1 |
suffix | string | "" | Text after the value, e.g. "%" |
formatValue | (value: number) => ReactNode | Custom readout under the knob | |
disabled | boolean | false | Dims the knob and ignores input |
Examples
Mixer strip
"use client"
import { useState } from "react"
import { Knob } from "@/components/breeze/knob"
export function KnobDemo() {
const [gain, setGain] = useState(64)
const [pan, setPan] = useState(-18)
return (
<div className="flex items-start gap-10">
<Knob label="Gain" value={gain} onChange={setGain} suffix="%" sound />
<Knob
label="Pan"
value={pan}
onChange={setPan}
min={-50}
max={50}
bipolar
color="#38bdf8"
formatValue={(v) => (v === 0 ? "C" : v < 0 ? `L${-v}` : `R${v}`)}
/>
</div>
)
}