ColorPicker
A composable hex color picker with a 2D saturation/brightness area, a hue slider, and a hex input
pnpm add @wandercom/design-system-web
import {
ColorPicker,
ColorPickerArea,
ColorPickerContent,
ColorPickerHueSlider,
ColorPickerInput,
ColorPickerTrigger,
} from '@wandercom/design-system-web/ui/color-picker';
export function Example() {
return (
<ColorPicker defaultValue="#6366f1" onValueChange={(value) => console.log(value)}>
<ColorPickerTrigger />
<ColorPickerContent>
<ColorPickerArea />
<ColorPickerHueSlider />
<ColorPickerInput />
</ColorPickerContent>
</ColorPicker>
);
}The default example shows the popover picker, inline mode, and the disabled state.
Set inline on the root to render the picker directly in the page instead of inside a popover. ColorPickerContent becomes a plain container and no trigger is needed.
<ColorPicker defaultValue="#22c55e" inline>
<ColorPickerContent className="rounded-lg border border-overlay-primary">
<ColorPickerArea />
<ColorPickerHueSlider />
<ColorPickerInput />
</ColorPickerContent>
</ColorPicker>Pass name to submit the current color (as a hex string) with the owning form via a hidden input. required, disabled, and readOnly are also supported.
<form>
<ColorPicker defaultValue="#6366f1" name="brandColor" required>
<ColorPickerTrigger />
<ColorPickerContent>
<ColorPickerArea />
<ColorPickerHueSlider />
<ColorPickerInput />
</ColorPickerContent>
</ColorPicker>
</form>value?:
defaultValue?:
onValueChange?:
open?:
defaultOpen?:
onOpenChange?:
inline?:
modal?:
name?:
disabled?:
readOnly?:
required?:
dir?:
labels?:
render?:
Accepts all PopoverContent props when rendered in a popover, including the positioning props (side, align, sideOffset, alignOffset, collisionPadding) and container to override the portal target.
render?:
className?:
Renders the design system Input and accepts all of its props except value, onChange, and color.
className?:
Every user-facing string is overridable through the labels prop on the root. Unspecified keys fall back to the English defaults in DEFAULT_COLOR_PICKER_LABELS.
hexInputLabel?:
hueSliderLabel?:
noColorSelectedLabel?:
hexPlaceholder?:
getSwatchLabel?:
- The 2D saturation/brightness area (
ColorPickerArea) is pointer-only. The hue slider and the hex input together form the complete keyboard-accessible alternative — every color reachable by dragging the area can also be reached with arrow keys on the slider or by typing an exact hex value into the input. - The hue slider is built on the Base UI Slider primitive and supports
Arrowkeys,Home,End,Page Up, andPage Down. ColorPickerSwatchrenders withrole="img"and announces the current color to screen readers (e.g. "Current color: #6366f1"), or "No color selected" when empty.- The hex input carries an accessible label describing its expected value.
- All user-facing strings — the input label, placeholder, and the swatch announcement — are localizable via the
labelsprop. - The trigger, slider, and input all show
:focus-visiblefocus indicators, and the popover follows the design system Popover focus behavior.
- The picker emits hex strings only (
#rrggbb); alpha is not supported, and any alpha in anrgba()or 8-digit-hex input value is stripped. - The 2D area does not accept keyboard input; keep the slider and input present whenever the area is used.