# Number scrub

A parameter you scrub sideways like a design tool field, with stops at the values that matter.

Also called: scrubber input, drag number input.

Example: Scrub a parameter. Drag a model setting sideways: the value follows, sticks for a moment at the defaults that matter, and a hairline shows where it sits. Preview: https://chatcn.dev/preview/number-scrub-demo

Press on the value and drag sideways: it follows the hand, sticks briefly at the values that matter (the defaults a model ships with), and a hairline under the field shows where it sits in the range. Hold Shift for fine moves. Double click, or press Enter, to type a number.

## Installation

```bash
npx shadcn@latest add https://chatcn.dev/r/number-scrub.json
```

## Usage

```tsx
import { NumberScrub } from "@/components/ui/chatcn/number-scrub"

<NumberScrub label="Temperature" value={t} onValueChange={setT} min={0} max={2} step={0.01} detents={[0, 0.7, 1]} />
```

## Examples

### Formats and detents

Example: Units, money and percent. Scrubbable fields with their own formats and detents: a timeout in ms and seconds, a sampling percent and a spend cap in dollars. Preview: https://chatcn.dev/preview/number-scrub-formats

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `label` | `string` |  |
| `value` / `onValueChange` | `number` |  |
| `min` / `max` / `step` | `number` | Step sets the decimals |
| `detents` | `number[]` | Values it sticks to |
| `format` | `(value) => string` | How it reads |
| `travel` | `number` | Pixels of drag across the range. Default 240 |

## Keyboard

| Key | Action |
| --- | --- |
| `ArrowRight` / `ArrowUp` | Up one step; with Shift, ten |
| `ArrowLeft` / `ArrowDown` | Down one step; with Shift, ten |
| `Home` / `End` | Minimum or maximum |
| `Enter` | Type a value |

## Accessibility

- `role="slider"` with the formatted value as its text; typing uses a real labelled input.

## Motion

- No animation while dragging (the value follows the hand); the fill eases 150 ms on key steps.

Source: https://chatcn.dev/docs/components/number-scrub