Knob
Updated
Knob is a pixel ring with an ink pointer over a native range input, for tuning panels. Drag up or right to turn it up; the arrow keys, Page Up/Down, Home and End work too, and screen readers read it as a slider. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.
Example
import "@/components/dithercharts/controls.css"
import { Knob } from "@/components/dithercharts/knob"
<Knob label="Gain" name="gain" defaultValue={60} onValueChange={(gain) => setGain(gain)} />
<Knob label="Dither" min={0} max={1} step={0.05} defaultValue={0.5} />Install
Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.
npx dithercharts add knob
Props
It renders a native element, so every other attribute that element takes passes through.
| Prop | Type | Default | Description |
|---|---|---|---|
| labelrequired | Type ReactNode | Default – | The caption above the dial, and its accessible name. |
| value | Type number | Default – | The value, for a controlled knob; pair it with onValueChange. |
| defaultValue | Type number | Default `min` | The value at first, for an uncontrolled knob. |
| onValueChange | Type (value: number) => void | Default – | Called with the new value as the knob turns. |
| min | Type number | Default 0 | |
| max | Type number | Default 100 | |
| step | Type number | Default 1 | |
| showValue | Type boolean | Default true | Shows the value under the dial. |
| name | Type string | Default – | The range input's form field name. |
| disabled | Type boolean | Default false | |
| className | Type string | Default – |

