Inspector Segmented

Dark Mode
About this component

Inspector Segmented

Settings row whose choices sit side by side on the right, with a marker that slides between them: the readable alternative to a switch when the two states deserve names, and the compact one to a select at three or four options.

Usage

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

import { InspectorSegmented } from "@/components/beste/component/inspector-segmented";

// A boolean that reads better named than toggled
<InspectorSegmented
  label="Dark Mode"
  options={[{ value: "off", label: "Off" }, { value: "on", label: "On" }]}
  value={darkMode ? "on" : "off"}
  onValueChange={(value) => setDarkMode(value === "on")}
/>

// Plain strings when the value is the text
<InspectorSegmented label="Fit" options={["Cover", "Contain"]} defaultValue="Cover" />

// Icons alone, for choices a word would only slow down
<InspectorSegmented
  label="Align"
  options={[
    { value: "left", icon: AlignLeft },
    { value: "center", icon: AlignCenter },
    { value: "right", icon: AlignRight },
  ]}
  value={align}
  onValueChange={setAlign}
/>

<InspectorSegmented
  label="Direction"
  icon={MoveHorizontal}   // optional leading icon
  tone="outline"          // "muted" (default) | "outline" | "ghost"
  size="sm"               // "sm" | "default" | "lg"
  options={[
    { value: "row", label: "Row" },
    { value: "column", label: "Column" },
    { value: "grid", label: "Grid", disabled: true },
  ]}
  value={direction}
  onValueChange={setDirection}
/>

// The segments are radios, so arrow keys move the selection and `name` submits
<InspectorSegmented label="Theme" name="theme" options={["System", "Light", "Dark"]} />

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.

Arrow keysMove through the segments; the value follows as you go.
Home / EndJump to the first or the last segment.

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.
options(string | InspectorSegmentedOption)[]—The choices. Plain strings are enough when the value is the text. Two to four segments is the range this reads well at; past that reach for inspector-select.
valuestring—Controlled value. Pair it with `onValueChange`.
defaultValuestring—Initial value in uncontrolled mode. Falls back to the first option.
onValueChange(value: string) => void—
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 shared by the underlying radios, so the row can take part in a form.
classNamestring—
aria-labelstring—Accessible name for the group. Falls back to `label`.

More Inspector components

View all Inspector
Borders