Back to elements
ElementForm & InputFree

Knob React component

A rotary dial for picking a value in a range, like a mixer control: drag up or down, scroll or use the keyboard, with a 270° progress ring and a sliding thumb, or a physical-looking knob with an indicator and ticks that light up as it turns.

When to use the Knob component

Use Knob in audio, video and creative tools, dashboards with dials, and settings panels where a compact circular control fits better than a long slider.

For precise numbers people will type, pair it with a number input or use a Slider instead.

Installation

Add the Knob component to your project with the shadcn CLI. It lands in components/knob.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add https://reactframe.com/r/knob.json

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install motion clsx tailwind-merge

Props

<Knob /> accepts 15 props, all optional.

  • value
    number
  • defaultValue
    number
    Default: 50
  • onValueChange
    (value: number) => void
  • min
    number
    Default: 0
  • max
    number
    Default: 100
  • step
    number
    Default: 1
  • label
    string
    Default: "Volume"
  • unit

    Text after the number, e.g. "%" or " dB".

    string
    Default: "%"
  • format

    Format the centre readout yourself.

    (value: number) => string
  • variant

    ring: a progress arc. dial: a physical-looking knob with an indicator and ticks.

    "ring" | "dial"
    Default: "ring"
  • size
    number
    Default: 128
  • color

    Arc colour.

    string
Show all 15 props
  • disabled
    boolean
    Default: false
  • theme
    "dark" | "light"
    Default: "dark"
  • className
    string

FAQ

How do I turn it?
Drag up or down (hold Shift for fine control), scroll the wheel over it, or focus it and use the arrow keys, Page Up / Down, Home and End.
Can I show my own units?
Use unit for a simple suffix or format to build the readout yourself, like +6 dB or 124 bpm.
Is it accessible?
It's a slider with its label, range, current value and readable value text, so screen readers announce changes.

More Form & Input components

Listbox
Free
Masked Input
Free
Toggle Button
Free
Input Group
Free
Button Group
Free
Floating Label Input
Free