Panel for choosing a solid colour or gradient: shade area, hue strip, hex and opacity.
Default
The full panel with Image, Solid and Gradient tabs; controlled with value and onChange.
Installation
Copies the component into src/design-system/ as your own source, with only the files it needs.
npx avesk-ui@latest add color-pickerBrings the 4 files it builds on (button.tsx, glyph.tsx, tabs.tsx, skeleton.tsx). The first time, it also adds the tokens and the cn() helper, imports the tokens in globals.css and installs clsx and tailwind-merge. Files already in your project are kept unless you add --force.
Import
Lives in src/design-system/components/color-picker.tsx.
import { normalizeHex, colorValueToCss, ColorPicker } from "@/design-system/components/color-picker";Usage
<ColorPicker value={{ kind: "solid", hex: "#ea580c", alpha: 100 }} onChange={setColor} modes={["solid"]} />Examples
Solid only
Limit modes to one tab to hide the tab bar, e.g. for a brand colour field.
Palette actions
onRemove shows a bin button and onAdd shows Add new color, for editing a palette.
Editing Denzing's primary colour
Disabled
Shows the colour but blocks changes, e.g. for a locked brand palette.
When to use
Use it when
- Editing a palette colour or a brand colour
Rules
- Controlled: pass value and onChange; use colorValueToCss() to preview
- Opened from a swatch → the default card with its shadow; placed on the page or in a panel → surface="inline" (no card, no shadow)
Properties
ColorPicker
| Prop | Type | Default |
|---|---|---|
value * | ColorValue | – |
onChange * | (value: ColorValue) => void | – |
modes | ColorPickerMode[] | ["image", "solid", "gradient"] |
onRemove | () => void | – |
onAdd | () => void | – |
disabled | boolean | – |
id | string | "color-picker" |
surface | "popover" | "inline" | "popover" |
className | string | – |
* required
Accessibility
- Shade area is a slider with arrow keys (Shift = ×10); hue is a native range