# Number wheel

Mechanical rolling digits. Each digit is a printed drum that turns to its figure, lowest digit first.

- Category: Instruments
- Built from: Amount
- Docs: https://bevel-ui.vercel.app/components/number-wheel
- Import from: `@/components/ui/number-wheel`

## Install

```bash
npx shadcn@latest add @bevel/number-wheel
```

npm dependencies (installed by the CLI): `cn`.

## Anatomy

```tsx
<NumberWheel value={1240} />
```

## Parts

| Part | Renders | Description |
| --- | --- | --- |
| `NumberWheel` | span | value with the same formatting options as Amount. tone is ivory or black. live sets whether screen readers hear changes: leave it off while a value ticks. |

## Example: Counter

Change the value and the drums roll to it. Sized by font size.

```tsx
"use client"

import * as React from "react"
import { NumberWheel } from "@/components/ui/number-wheel"

export function NumberWheelCounter() {
  const [value, setValue] = React.useState(1240)
  const buttons = [
    { label: "+1", change: 1 },
    { label: "+99", change: 99 },
    { label: "−250", change: -250 },
  ]
  return (
    <div className="flex flex-col items-center gap-6">
      <NumberWheel value={value} live="polite" className="text-5xl" />
      <NumberWheel value={value / 100} currency="USD" tone="black" className="text-2xl" />
      <div className="flex gap-2">
        {buttons.map((button) => (
          <button
            key={button.label}
            type="button"
            onClick={() => setValue((v) => Math.max(0, v + button.change))}
            className="h-9 rounded-md border px-3 text-sm font-medium hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
          >
            {button.label}
          </button>
        ))}
      </div>
    </div>
  )
}
```
