Number scrub
A parameter you scrub sideways like a design tool field, with stops at the values that matter.
On this page
Drag a model setting sideways: the value follows, sticks for a moment at the defaults that matter, and a hairline shows where it sits.
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
Usage
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
Scrubbable fields with their own formats and detents: a timeout in ms and seconds, a sampling percent and a spend cap in dollars.
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.