Knob

Rotary dial. The needle follows your drag on a weighted spring, each step clicks, and the gap at the bottom is a hard stop rather than a wrap. Fully keyboard driven. Inputs.

Open playground
Volume

About

Knob is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { Knob } from "@ashutoshswamy/smoui" and set label, value, min among its 6 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { Knob } from "@ashutoshswamy/smoui";

<Knob label="Volume" defaultValue={62} min={0} max={100} step={1} onChange={setVolume} />

Props 6

label

Accessible name and caption.

string
value / defaultValue

Controlled or initial value.

numberdefault 40
min / max / step

Range and snap increment.

numberdefault 0 / 100 / 1
format

Text for the centre readout.

(value: number) => string
size

Diameter in px.

numberdefault 140
onChange

Called on each step.

(value: number) => void