Color inspector

Edits a six-digit hex color and alpha with a data-driven preview, a transparency ground, and native form validation.

Fill

#808080, alpha 0.75

Inspect the fill

Selected shape

Fill

#808080, alpha 0.75

Use it for

  • Application-owned color data; only the swatch uses the supplied hue, while the inspector shell stays monochrome.
  • Six-digit hex including #, with alpha from zero transparent to one opaque.
  • onValueChange receives editable input; incomplete alpha is null and invalid hex remains available for correction.

Not for

  • Assuming color-space conversion, gamut checking, contrast certification, or color-profile management.
  • Presenting a valid preview when the supplied color or alpha is invalid.

Three ways in. They share one source, so the pixels match whichever you pick.

1. Import the package

npm install @noorddev/vlak-react

// once, next to your app's root
import "@noorddev/vlak-react/css";

import { ColorInspector } from "@noorddev/vlak-react";

Precompiled React and one stylesheet. No compiler to configure. Per-component imports work too: @noorddev/vlak-react/components/color-inspector.

2. Vendor the source

npx @noorddev/vlak-cli add color-inspector

The StyleX leaf lands in components/vlak/ with its dependencies, for your own compiler to own. See StyleX.

3. Through shadcn

npx shadcn add https://vlak.dev/r/color-inspector.json

The same registry item, installed by shadcn's CLI.

CSS only

<link rel="stylesheet" href="node_modules/@noorddev/vlak/css/vlak.css" />

No React. Link vlak.css and use the markup and classes below.

import { ColorInspector } from "@noorddev/vlak-react";

<ColorInspector label="Fill" name="fill" defaultValue={{ hex: "#808080", alpha: 0.5 }} />

ColorInspector

A data swatch and editable six-digit hex and alpha, on a monochrome shell.

PropTypeDefaultDescription
labelrequiredReactNode
valueInspectorColor
defaultValueInspectorColorinitial
onValueChange(value: InspectorColor) => voidReceives editable hex text and alpha, including incomplete values.
readOnlyboolean

Also accepts Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "defaultValue" | "onChange">.

KeysDoes
TabMoves between the native hex and alpha inputs.
Text editing keysEdits or selects hex and alpha values; any alpha precision from 0 to 1 is accepted.
<fieldset class="rs-color-inspector"><legend class="rs-color-inspector-label">Fill</legend><div class="rs-color-inspector-preview" aria-hidden="true"><span class="rs-color-inspector-swatch" style="background-color:#808080;opacity:0.5"></span></div><div class="rs-color-inspector-fields"><label class="rs-color-inspector-field">Hex<input class="rs-input rs-input-full rs-color-inspector-input" type="text" value="#808080" pattern="#[0-9a-fA-F]{6}" required /></label><label class="rs-color-inspector-field">Alpha<input class="rs-input rs-input-full rs-color-inspector-input" type="number" value="0.5" min="0" max="1" step="any" required /></label></div></fieldset>
.rs-color-inspector.rs-color-inspector-label.rs-color-inspector-preview.rs-color-inspector-swatch.rs-color-inspector-fields.rs-color-inspector-field.rs-color-inspector-input.rs-color-inspector-note