Inspect the fill
Selected shape
Edits a six-digit hex color and alpha with a data-driven preview, a transparency ground, and native form validation.
Selected shape
Three ways in. They share one source, so the pixels match whichever you pick.
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.
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.
npx shadcn add https://vlak.dev/r/color-inspector.json
The same registry item, installed by shadcn's CLI.
<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 }} />A data swatch and editable six-digit hex and alpha, on a monochrome shell.
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | ReactNode | ||
value | InspectorColor | ||
defaultValue | InspectorColor | initial | |
onValueChange | (value: InspectorColor) => void | Receives editable hex text and alpha, including incomplete values. | |
readOnly | boolean |
Also accepts Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "defaultValue" | "onChange">.
| Keys | Does |
|---|---|
| Tab | Moves between the native hex and alpha inputs. |
| Text editing keys | Edits 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>