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)}
/>

Playground

Turn the props on the right; the snippet under them is what you would write to get what you see.

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

<InspectorColor
  label="Color"
  className="w-72"
  defaultValue="#171717"
/>

Props

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

PropTypeDefaultDescription
label*stringLabel rendered on the left, inside the row.
iconLucideIconOptional leading icon shown before the label.
valuestringControlled colour. Pair it with `onValueChange`.
defaultValuestringInitial colour in uncontrolled mode.
onValueChange(value: string) => voidFires on every adjustment, including each frame of a drag in the picker.
onValueCommit(value: string) => voidFires 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) => voidFires when the picker opens or closes.
format"hex" | "oklch" | "rgb""hex"Notation written back through the callbacks.
alphabooleanCarry an alpha channel, and show its rail in the picker.
swatchesstring[]Preset colors offered inside the picker.
disabledbooleanBlock 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-labelstringAccessible name. Falls back to `label`.

More Inspector components

View all Inspector
Color stops

Inspector Multicolor

Settings row for a list of colors: a swatch per stop, each opening the OKLCH picker, and a remove and add pair at the far right bounded by min and max.

Inspector Select

Settings row that pairs a label with its current choice inside one pill, opening a width-matched dropdown below: option icons, colour swatches, descriptions and grouped sections, on top of the accessible shadcn select.

Inspector Input

Settings row with a label on the left and a plain text field on the right, sharing the family's pill: the whole row is the label, so pressing anywhere puts the caret in the field.

Borders

Inspector Toggles

Settings row holding a set of pills that are each on or off, so any number of them can be on at once: what inspector-segmented is for one choice out of several, this is for several choices at once, and what inspector-switch is for a single flag, this is for a handful that belong together.

Inspector Switch

Settings row with a label on the left and a switch on the right, sharing the family's pill: the label takes the row's spare width, so a press almost anywhere toggles it.

Inspector Icon

Settings row that names the chosen icon and shows it on the right; pressing the row opens a searchable palette below it, width-matched to the row, with clearing offered at the foot of it. The icon set is passed in, so the row never bundles an icon library of its own.