Scrub Input

Figma-style drag-to-change number field

Drag horizontally across the label to scrub the value — hold Shift for ×10 or Alt for ×0.1 — or click the number to type it directly. Arrow keys nudge when the field is focused.

Preview

W180px
R16px
O0.90

Drag a label or type a value.

Preview
180px · 16px · 0.90

Installation

Install the component using the CLI.

npx shadcn@latest add https://rohan.run/r/scrub-input.json

Usage

Import the component:

import { ScrubInput } from "@/components/rohan/scrub-input"

Use it in your code:

<ScrubInput
  label="W"
  defaultValue={320}
  min={0}
  max={1920}
  suffix="px"
  onChange={(value) => setWidth(value)}
/>

Props

PropertyTypeDefaultDescription
labelstringShort label shown in the drag zone, e.g. "W".
defaultValuenumber0Initial value.
min / maxnumber±InfinityClamp range for the value.
stepnumber1Snap increment. Decimal steps set the displayed precision.
suffixstringUnit rendered after the number, e.g. "px".
sensitivitynumber0.5Value change per pixel dragged.
onChange(value: number) => voidFires on every committed change.
Components