This page as markdown: /scrub-field.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

ScrubField

Status: stable

The compact numeric field a property grid is built from: a leading glyph inside the field that doubles as a drag-to-scrub handle, the value, and an optional unit.

Keywords: scrub, numeric, number, field, property, inspector, drag, workspace, tool, unit

Usage

Use ScrubField for numeric properties in tool chrome — an inspector, a property grid, a panel. The leading icon or letter says what the number is and is also the thing you drag, which is why a value like opacity needs no slider. Reach for NumberField instead in page-register forms: it has steppers and locale formatting, and it renders at page-register height. Those two steppers put a ~112px floor on a control that needs to be about 44px in a property grid, which is why ScrubField exists rather than a NumberField size variant. The input is sized in ch, so each field is as wide as its longest value and a grid of them lines up without per-field tuning.

Best practices

Props

Name Type Default Description
value number — The current value (controlled).
onValueChange (next: number) => void — Fires on commit, arrow-key step, and every frame of a scrub.
min number — Lower clamp, applied to typing and scrubbing.
max number — Upper clamp, applied to typing and scrubbing.
step number 1 Arrow-key and scrub increment, and the source of display precision. Shift multiplies arrows by 10 and divides scrubbing by 10.
label string — Accessible name for the input. Required — the visible glyph is decorative.
icon string — Semantic icon name rendered inside the field; doubles as the scrub handle. Any name the app's IconProvider resolves works — image tools typically supply their own checkerboard glyph for opacity, which is a domain icon rather than one Sable's contract carries.
prefix ReactNode — Short text used instead of an icon (e.g. "X" / "Y"), with the same scrub role.
suffix ReactNode — Unit rendered after the value inside the field (e.g. "%", "px").
onGestureStart () => void — Fires once when a scrub drag begins — open an undo transaction here, and drop expensive downstream work (e.g. a GPU renderer) to a cheap preview quality; without it a pipeline re-renders at full quality on every pointer move and the drag stutters.
onGestureEnd () => void — Fires when a scrub drag ends — close the undo transaction here and restore full render quality.
disabled boolean — Disables typing and scrubbing; a disabled field submits nothing, like a native control.
readOnly boolean — Blocks typing, arrow keys and scrubbing. The value still submits.
name string — Submits the value with a form under this name, through a hidden input: a plain number at the precision of step ("60", "0.25") — no unit, no separators. It is always the last committed value, never the draft being typed.
form string — Id of a form elsewhere on the page that the hidden input belongs to.
id string — Input id, for a PropertyRow's htmlFor.
className string — Sizes the field shell (w-16, flex-1). Defaults to w-full.
dragLabel (label: string) => string (label) => Drag to change ${label} The scrub handle's tooltip, given label. Translate it with the rest of the panel.
...props ComponentPropsWithRef<"input"> — ref, aria-describedby, aria-invalid, required, data-* and handlers land on the input, so a Field's description and error reach it and a ref can focus it.

Tokens used

foreground, muted-foreground, ring, panel-field, panel-field-hover

Motion

Accessibility

Related

Examples

In a form (submits the committed number)

import { ScrubField } from "@sableui/react"

<form action={save}>
  <ScrubField label="Opacity" name="opacity" icon="grid" suffix="%" value={opacity} min={0} max={100} onValueChange={setOpacity} />
</form>

Opacity with a glyph handle

import { ScrubField } from "@sableui/react"

<ScrubField label="Opacity" icon="grid" suffix="%" value={60} min={0} max={100} onValueChange={(v) => setOpacity(v)} />

X/Y offset pair (PropertyPair puts two fields on one scan line)

import { PropertyPair, ScrubField } from "@sableui/react"

<PropertyPair labels={["Offset X", "Offset Y"]}>
  <ScrubField label="Offset X" prefix="X" value={x} min={-128} max={128} onValueChange={setX} />
  <ScrubField label="Offset Y" prefix="Y" value={y} min={-128} max={128} onValueChange={setY} />
</PropertyPair>

No glyph — the property name is the handle

import { PropertyRow, ScrubField } from "@sableui/react"

<PropertyRow label="Block size" scrub={{ value: size, onValueChange: setSize, min: 2, max: 256 }}>
  <ScrubField label="Block size" value={size} min={2} max={256} suffix="px" onValueChange={setSize} />
</PropertyRow>

Paired with a slider (no glyph — one drag affordance per row)

import { PropertyRow, ScrubField, Slider } from "@sableui/react"

<PropertyRow label="Block size" stacked>
  <div className="flex items-center gap-2">
    <Slider value={32} min={4} max={256} className="min-w-0 flex-1" />
    <ScrubField label="Block size" value={32} min={4} max={256} step={1} suffix="px" className="w-16 shrink-0" onValueChange={(v) => setBlockSize(v)} />
  </div>
</PropertyRow>