docs / core / knob
Knob
one number, set by turning: a level, a mix, a gain. it earns its circle when several sit in a row and get balanced against each other. for a single value in a settings list, Slider reads faster.
intensity · recedesrsc · client
provenance
authored in usvalayer
core / primitivesintensity
recedes · safe anywhere, including dense surfacescomposition
banks of related values tuned against one anotherdrag the ring to dial it, or the body left and right to scrub. hold shift on either for fine controlpair label with showValue so the number survives the dragonValueCommitted to persist, onValueChange to previewnot a dial for one lonely setting. that is a Slidernot a readout. Progress and StatChip display, this one acceptsa11y
role="slider" named by its label · arrows step, Home and End reach the bounds, PageUp and PageDown move by ten, shift gives a tenth · the dial takes the focus ring, and the whole square is the hit target · no wheel handler, so scrolling the page over it stays scrolling the pagejest-axedependencies
class-variance-authoritylive demo · try it out
Gain6 dB
customize
labeltext above the dial
sizesm is for dense rows
minlower bound
maxupper bound
stepincrement per tick
defaultValuestarting angle
suffixunit appended to the readout
showValuevalue readout under the dial
disableddims and ignores input
usage
import { Knob } from "@usva-ui/react/primitives/knob";
<Knob
label="Gain"
defaultValue={6}
min={-12}
max={12}
step={3}
showValue
formatValue={(v) => `${v} dB`}
/>props
| prop | type | default | notes |
|---|---|---|---|
| value | number | — | controlled value. |
| defaultValue | number | — | initial value when uncontrolled. |
| onValueChange | (value: number) => void | — | fires on every change, mid-drag and per key press. |
| onValueCommitted | (value: number) => void | — | fires once the pointer or key is released. use this to persist. |
| min | number | 0 | lower bound. |
| max | number | 100 | upper bound. |
| step | number | 1 | increment per arrow key press, and the grid every drag snaps to. |
| disabled | boolean | false | dims to 50% and ignores pointer and keyboard. |
| label | ReactNode | — | label above the dial. also names the knob for screen readers. |
| showValue | boolean | — | current value under the dial, in mono with tabular figures. |
| formatValue | (value: number) => string | — | formats the readout and the value announced to screen readers. |
| size | "sm" | "md" | "lg" | "md" | dial diameter, 44 / 64 / 96px. |
get it
bun add @usva-ui/reactusage
import { Knob } from "@usva-ui/react/primitives/knob";
<Knob label="Volume" defaultValue={59} showValue formatValue={(v) => `${v} %`} />