Skip to content
Sign upGet access
MicrointeractionsNumber scrubMenu

Number scrub

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

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

$ pnpm dlx 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

Scrubbable fields with their own formats and detents: a timeout in ms and seconds, a sampling percent and a spend cap in dollars.

Props

PropTypeNotes
labelstring
value / onValueChangenumber
min / max / stepnumberStep sets the decimals
detentsnumber[]Values it sticks to
format(value) => stringHow it reads
travelnumberPixels of drag across the range. Default 240

Keyboard

KeyAction
ArrowRight / ArrowUpUp one step; with Shift, ten
ArrowLeft / ArrowDownDown one step; with Shift, ten
Home / EndMinimum or maximum
EnterType 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.