Captain UI

Scrub number

A number field you scrub by dragging its label: Shift for ten times faster, Alt for a tenth. Click the number to type, and the digits roll as it changes.

npx shadcn@latest add https://captain-ui.vercel.app/r/scrub-number.json

Batch run

Runs
Each
Temperature
Timeout
s

Budget for the batch

$44.40

24 runs × $1.85

Drag any label sideways to scrub its number, or click the number to type.

Usage

import { ScrubNumber } from "@/components/ui/scrub-number"

<ScrubNumber label="Timeout" defaultValue={90} min={5} max={600} step={5} unit="s" />

Props

PropTypeDefaultWhat it does
valuenumberControlled value.
defaultValuenumber0Initial value when uncontrolled.
onValueChange(value: number) => voidCalled while scrubbing, on arrow keys and when typing is committed.
labelReactNodeThe field's name and its drag handle.
min / maxnumber-∞ / ∞Past a limit the number leans like rubber and springs back.
stepnumber1One step per pixelsPerStep of drag, and per arrow key.
pixelsPerStepnumber2How far to drag for one step.
prefix / unitstringShown before and after the number, e.g. $ and s.
format(value: number) => stringFormats the number. Defaults to grouped digits at the step's precision.
disabledbooleanDims and ignores input.

Keyboard

↑ ↓
One step
Shift + ↑ ↓
Ten steps
Alt + ↑ ↓
A tenth of a step
Enter
Commit what you typed
Escape
Discard what you typed

Accessibility

  • The field is a real text input with role=spinbutton, aria-valuenow and its limits.
  • The label names the input, so scrubbing is optional: arrows and typing do the same.
  • The rolling digits are decorative and hidden from screen readers.