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.

0Volume
Props
Color
theme
Size88
Ticks36
Min0
Max100
Click volume0.35

Installation

pnpm dlx shadcn@latest add @breeze/knob

Usage

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

PropTypeDefaultDescription
labelstringText under the value, also the accessible name
valuenumberControlled value
defaultValuenumbermin (centre if bipolar)Starting value when uncontrolled, and the double-click reset target
onChange(value: number) => voidCalled with each new value
minnumber0Lowest value
maxnumber100Highest value
stepnumber1Value increment
colorstring"var(--brand)"Lit ticks and the pointer notch, any CSS colour or var()
sizenumber88Diameter in px
ticksnumber36Tick marks around the ring
bipolarbooleanfalseLight the ticks from the centre of the range
soundbooleanfalseClick as the value crosses each tick
volumenumber0.35Click volume, 0 to 1
suffixstring""Text after the value, e.g. "%"
formatValue(value: number) => ReactNodeCustom readout under the knob
disabledbooleanfalseDims the knob and ignores input

Examples

Mixer strip

64%Gain
L18Pan
3.2Tone
40%Mix