On this page

InstallationWhat it isAPI Reference

Color picker

A color from our tokens, with its opacity: a semantic token or a stop of the scales, or moved from one, its lightness and chroma changed and its hue kept.

1<ColorPicker defaultValue={{ token: "green-800" }} />

Installation

text
import { ColorPicker } from "@dome-systems/ds-dashboard/components";

What it is

Closed, an xxs Button: the color's square, the token's name (“, custom” once moved), cut with “…” in a narrow row, and a chevron. Open, a Popover with two tabs of one height, Tokens and Picker. Every change is live, with nothing to apply; only a click outside or Escape closes it.

Tokens: the semantic tokens, a family a row (Neutral first), in three labelled groups, Foreground, Background and Border, above the scales, a ramp a row. One tooltip names them all and slides from swatch to swatch. A click picks a token and keeps the opacity; the arrow keys move between them. Under them, the picked token's name and hex, read only, and its opacity, which changes here.

Picker: the token's color as the page draws it now (a semantic token's follows the theme), a square of lightness by chroma at its hue, as far as sRGB reaches, with the ramp's stops marked on it; then L, C and H (locked), the hex and the opacity. A move here makes the color custom; picking a token drops it. A typed hex applies at six digits: a stop's own hex picks that stop, any other is that color, moved from the nearest stop. The math is lib/oklch.ts. To paint the value: tokenColorCss(value).

API Reference

PropTypeDefaultDescription
valueTokenColor: { token: string; opacity?: number; custom?: { l; c; h } }—The token ("link", "green-800"), its opacity 0 to 100 (decimals allowed), and once moved in the Picker the color it was moved to. With onValueChange, controlled.
defaultValueTokenColor—The color it starts on when it holds its own. purple-900 unless set.
onValueChange(value: TokenColor) => void—Every change, as it happens: a token picked, the opacity, a hex typed, each move in the Picker.
align"start" | "end"—The trigger's edge the popover lines up with. start unless set; end for a trigger at a row's right end (the Tuner's), whose end stays put when a longer name widens it.