# Detent Dial

Rotary knob that clicks from notch to notch and coasts when flicked, built with React and Motion.

Install with

```bash
npx shadcn@latest add https://kokonutui.com/r/detent-dial.json
```

## Installation

Detent Dial is a free, open-source React component in the Kokonut UI [Inputs collection](/content/docs/inputs/index.html). Add it with the shadcn CLI, which copies the source into `components/kokonutui/detent-dial.tsx`, so the code is yours to change.

```bash
npx shadcn@latest add @kokonutui/detent-dial
```

Or add it by hand: install its packages, then copy the source from the above into `components/kokonutui/detent-dial.tsx`.

```bash
npm install motion
```

## Usage

```javascript
import DetentDial from "@/components/kokonutui/detent-dial";

export default function Example() {
  return <DetentDial />;
}
```

## Props

| Prop           | Type     | Default     | Description                                                 |
|----------------|----------|-------------|-------------------------------------------------------------|
| `label`        | `string` | `"Temperature"`   | Accessible name, also shown inside the knob.               |
| `min`          | `number` | `16`        | Minimum value.                                             |
| `max`          | `number` | `30`        | Maximum value.                                             |
| `step`         | `number` | `0.5`       | Increment step.                                           |
| `defaultValue` | `number` | `21`        | Initial value when uncontrolled. Double-clicking returns here. |
| `value`        | `number` |             | Controlled value.                                         |
| `onValueChange`| `(value: number) => void` |  | Callback to capture value changes.                      |
| `formatValue`  | `(value: number) => string` | Default `(v) => `${v.toFixed(1)}°`
 | Formats the readout, end labels and `aria-valuetext`.  |
| `size`         | `number` | `240`       | Diameter in px.                                          |
| `disabled`     | `boolean`| `false`     | Disable the component.                                    |
| `className`    | `string` |             | Extra classes for the root element.                       |

## Dependencies

| Needs                            | Version     | Comes from                      |
|----------------------------------|-------------|---------------------------------|
| `motion`                         | `^12.23.25`| npm, installed by the CLI     |
| `cn` from `lib/utils.ts`        |             | shadcn init                    |
| React                            | `19`       | Your app                       |
| Tailwind CSS                     | `4`        | Your app                       |

No provider, font or global CSS to set up: the file works as soon as it lands.
