Inspector Dimensions

px
About this component

Inspector Dimensions

Width and height on one row, with the lock between them: while it is closed, editing one scales the other by the ratio the pair had when the lock closed. Both fields are as wide as the largest number they can hold, so typing never shifts the row.

Usage

The import and the props worth knowing about, in one place.

import { InspectorDimensions } from "@/components/beste/component/inspector-dimensions";

<InspectorDimensions label="Size" defaultValue={{ width: 1280, height: 720 }} defaultLocked />

<InspectorDimensions
  label="Canvas"
  value={size}                    // { width, height }
  onValueChange={setSize}         // every accepted edit
  onValueCommit={(next) => console.log("settled on", next)}  // Enter or blur
  locked={locked}                 // controlled lock; pair it with onLockedChange
  onLockedChange={setLocked}
  min={16}
  max={4096}
  step={8}                        // arrows step by this, Shift by ten of them
  precision={0}                   // decimals kept, which matters because a locked edit divides
  suffix="px"                     // printed once, after the pair
  name="canvas"                   // fields submit as canvas-width and canvas-height
  tone="outline"                  // "muted" (default) | "outline" | "ghost"
  size="sm"                       // "sm" | "default" | "lg"
/>

// A pair whose numbers are genuinely unrelated
<InspectorDimensions label="Grid" lockable={false} defaultValue={{ width: 12, height: 6 }} suffix="" />

Keyboard and gestures

Every one of these is in the component already. They are listed because a props table cannot mention a gesture, so nothing else on this page can tell you they exist.

Up / DownStep the focused number
Shift + Up / DownStep it by ten
EnterAccept what was typed
EscapeThrow away what was typed and put the value back
LockTies the two together at the ratio they have when it closes

Props

Read from the component's own type, so this cannot drift from what it accepts.

PropTypeDefaultDescription
label*string—Label rendered on the left, inside the row.
iconLucideIcon—Optional leading icon shown before the label.
valueDimensions—Controlled value. Pair it with `onValueChange`.
defaultValueDimensions—Initial value in uncontrolled mode.
onValueChange(value: Dimensions) => void—Fires on every accepted edit.
onValueCommit(value: Dimensions) => void—Fires once an edit is finished — the field left, or Enter pressed.
minnumber0 to 9999, in steps of 1Range both numbers answer to.
maxnumber—
stepnumber—
precisionnumber2How many decimals a value keeps, which matters here because a locked edit divides.
suffixstring"px"Unit printed after the pair, once, since both numbers are in it.
lockedboolean—Whether the two are tied together. Pair it with `onLockedChange`. While they are, editing one scales the other by the ratio they had when the lock closed.
defaultLockedboolean—Initial lock state in uncontrolled mode.
onLockedChange(locked: boolean) => void—
lockableboolean—Take the lock away, for a pair whose numbers are genuinely unrelated.
disabledboolean—Block interaction and dim the row.
tone"muted" | "outline" | "ghost""muted"Surface treatment: filled (default), hairline outline, or bare until hover.
size"sm" | "default" | "lg""default"Row height preset.
namestring—Name of the fields, so the pair can take part in a form.
classNamestring—
aria-labelstring—Accessible name. Falls back to `label`.

More Inspector components

View all Inspector
Dark Mode