Inspector Color

About this component

Inspector Color

Settings row that keeps the label, the colour value and a swatch on one pill; pressing the row opens the OKLCH colour picker below it, which is where the value is edited.

Usage

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

import { InspectorColor } from "@/components/beste/component/inspector-color";

// The value is a readout, and the whole row opens the picker
<InspectorColor label="Color" defaultValue="#171717" />

// Controlled, with a separate commit for expensive work
<InspectorColor
  label="Dot color"
  value={dotColor}
  onValueChange={setDotColor}                          // every adjustment
  onValueCommit={(value) => console.log("persist", value)} // once per gesture
  swatches={["#171717", "#6366f1", "#0ea5e9", "#10b981"]}
/>

<InspectorColor
  label="Overlay"
  icon={Layers}          // optional leading icon
  value={overlay}
  onValueChange={setOverlay}
  alpha                  // 8-digit hex, checkerboard behind the swatch
  tone="outline"         // "muted" (default) | "outline" | "ghost"
  size="sm"              // "sm" | "default" | "lg"
/>

// Theme tokens: write oklch() back out
<InspectorColor
  label="Primary"
  format="oklch"
  value={theme.primary}
  onValueChange={(value) => console.log(value)}
/>

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.
valuestring—Controlled colour. Pair it with `onValueChange`.
defaultValuestring—Initial colour in uncontrolled mode.
onValueChange(value: string) => void—Fires on every adjustment, including each frame of a drag in the picker.
onValueCommit(value: string) => void—Fires once an adjustment is finished — a drag release, a committed edit, a swatch click. Use it for work too expensive to run per frame.
onOpenChange(open: boolean) => void—Fires when the picker opens or closes.
format"hex" | "oklch" | "rgb""hex"Notation written back through the callbacks.
alphaboolean—Carry an alpha channel, and show its rail in the picker.
swatchesstring[]—Preset colors offered inside the picker.
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
Color stops