Inspector Tracks

About this component

Inspector Tracks

The columns of a grid as a list of lengths: the row shows the CSS it comes to, the editor holds one length per line with a picture of the shares above them. There is no reordering on purpose, because a track's place in the list is its place in the grid.

Usage

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

import { InspectorTracks, tracksToCss } from "@/components/beste/component/inspector-tracks";

<InspectorTracks
  label="Columns"
  defaultValue={[
    { size: 1, unit: "fr" },
    { size: 2, unit: "fr" },
    { size: 240, unit: "px" },
  ]}
/>

<InspectorTracks
  label="Rows"
  value={rows}
  onValueChange={setRows}
  onOpenChange={(open) => console.log("editor open:", open)}
  units={["fr", "px", "auto"]}   // ["fr", "px", "%", "auto"] by default
  minTracks={2}
  maxTracks={6}
  tone="outline"                 // "muted" (default) | "outline" | "ghost"
  size="sm"                      // "sm" | "default" | "lg"
/>

// The value is only useful once it is a template, so the join ships with it
<div style={{ display: "grid", gridTemplateColumns: tracksToCss(columns) }}>{children}</div>

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 track size
Shift + Up / DownStep it by ten
EnterAccept what was typed
EscapeThrow away what was typed, or close the editor

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.
valueTrack[]—Controlled value. Pair it with `onValueChange`.
defaultValueTrack[]—Initial value in uncontrolled mode.
onValueChange(value: Track[]) => void—
onOpenChange(open: boolean) => void—Fires when the editor opens or closes.
unitsstring[]["fr", "px", "%", "auto"]The units a track may be measured in. `auto` is understood as "the contents decide", and its number field steps aside.
minTracksnumber1 to 12How many tracks there may be.
maxTracksnumber—
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.
classNamestring—
aria-labelstring—Accessible name. Falls back to `label`.

More Inspector components

View all Inspector
landing pagesaaspricing