Color Picker

Picks a colour by dragging, entering hex or choosing a preset.

Brand accent

Installation

pnpm dlx shadcn@latest add @paneui/color-picker

Usage

Composition

Examples

With Alpha

Inline

Change vs Commit

Swatch Trigger

Disabled

Keyboard

The area thumb is a 2D slider; arrow keys nudge saturation and brightness 1% (Shift for 10%). Hue and alpha are sliders. The hex field commits on Enter or blur, reverts invalid input, and Escape restores the last value.

Motion

With reduced motion the panel fades instead of growing from the trigger, and the area thumb barely scales while dragging.

API Reference

Built on the Popover primitive. Only the props this library adds or changes are listed; everything else passes through.

ColorPicker

Colour state plus the popover root. Parts also work inline without trigger and content. Also accepts every prop of Popover.Root.

value
string
Controlled hex colour (#rrggbb or #rrggbbaa).
defaultValue= theme `--primary`
string
Initial colour when uncontrolled. Without it the picker starts on the live --primary token (read after mount; #171717, the default light primary, during server render).
onValueChange
(hex: string) => void
Fires continuously while dragging or typing.
onValueCommit
(hex: string) => void
Fires once when a gesture ends (pointer up, key, hex commit, preset); onValueChange fires continuously while dragging.
alpha= false
boolean
Allow transparency; without it alpha is always 1.
disabled= false
boolean
Disable the trigger and all parts.
PropTypeDefaultDescription
valuestring—Controlled hex colour (#rrggbb or #rrggbbaa).
defaultValuestringtheme `--primary`Initial colour when uncontrolled. Without it the picker starts on the live --primary token (read after mount; #171717, the default light primary, during server render).
onValueChange(hex: string) => void—Fires continuously while dragging or typing.
onValueCommit(hex: string) => void—Fires once when a gesture ends (pointer up, key, hex commit, preset); onValueChange fires continuously while dragging.
alphabooleanfalseAllow transparency; without it alpha is always 1.
disabledbooleanfalseDisable the trigger and all parts.

ColorPickerTrigger

Raised chip with the swatch and hex. Pass children to replace its content. Also accepts every prop of Popover.Trigger.

showHex= true
boolean
Show the hex label next to the swatch.
PropTypeDefaultDescription
showHexbooleantrueShow the hex label next to the swatch.

ColorPickerContent

Portal, positioner and 256px popup that grows out of the trigger. Also accepts every prop of Popover.Popup.

align= "start"
"start" | "center" | "end"
Trigger edge the panel lines up with.
collisionPadding= 8
number | Padding
Space kept from the viewport edges.
triggerRadius= "var(--radius-lg)"
string
Corner radius (CSS length) of the trigger shape the panel morphs from. The default matches ColorPickerTrigger; change it only if you reshape the trigger.
PropTypeDefaultDescription
align"start" | "center" | "end""start"Trigger edge the panel lines up with.
collisionPaddingnumber | Padding8Space kept from the viewport edges.
triggerRadiusstring"var(--radius-lg)"Corner radius (CSS length) of the trigger shape the panel morphs from. The default matches ColorPickerTrigger; change it only if you reshape the trigger.

ColorPickerArea

Saturation (x) by brightness (y) plane with a draggable thumb. Also accepts every prop of div.

label= the locale's
string
Accessible name of the thumb.
PropTypeDefaultDescription
labelstringthe locale'sAccessible name of the thumb.
data-disabled
Present when the picker is disabled.
Data attributeDescription
data-disabledPresent when the picker is disabled.

ColorPickerHue

Hue slider (0–360). Value, range and change handlers are owned by the picker; other props go to the slider root. Also accepts every prop of Slider.Root.

label= the locale's
string
Accessible name of the thumb.
disabled= false
boolean
Disable this slider; the root's disabled also applies.
PropTypeDefaultDescription
labelstringthe locale'sAccessible name of the thumb.
disabledbooleanfalseDisable this slider; the root's disabled also applies.

ColorPickerAlpha

Opacity slider over a checkerboard. Only meaningful with alpha on the root. Other props go to the slider root, as for ColorPickerHue. Also accepts every prop of Slider.Root.

label= the locale's
string
Accessible name of the thumb.
disabled= false
boolean
Disable this slider; the root's disabled also applies.
PropTypeDefaultDescription
labelstringthe locale'sAccessible name of the thumb.
disabledbooleanfalseDisable this slider; the root's disabled also applies.

ColorPickerHexInput

Hex field in an inset well; full 6 or 8-digit values apply while typing, and values below full opacity come out as 8-digit hex. Also accepts every prop of input.

aria-label= the locale's
string
Accessible name of the field.
PropTypeDefaultDescription
aria-labelstringthe locale'sAccessible name of the field.

ColorPickerSwatch

The current colour over a checkerboard so transparency shows (20px; resize with size-*). Also accepts every prop of span.

ColorPickerPresets

Wrapping group of preset buttons, labelled Presets. Also accepts every prop of div.

ColorPickerPreset

One preset swatch button, an 18px swatch in a 24px hit area, with a ring when aria-pressed (it matches the current colour). Also accepts every prop of button.

value*
string
Hex colour applied on click.
label
string
Accessible name. Defaults to the hex value.
PropTypeDefaultDescription
value*string—Hex colour applied on click.
labelstring—Accessible name. Defaults to the hex value.

useColorPicker

Current colour and setters for custom parts. Use inside ColorPicker.

hsva
{ h: number; s: number; v: number; a: number }
Current colour; h 0–360, others 0–1.
hex
string
Current colour as lowercase hex.
setHsva
(next: Hsva, commit?: boolean) => void
Set the colour; commit also fires onValueCommit.
commit
() => void
Fire onValueCommit with the current colour.
alpha
boolean
Whether alpha is enabled.
disabled
boolean
Whether the picker is disabled.
PropTypeDefaultDescription
hsva{ h: number; s: number; v: number; a: number }—Current colour; h 0–360, others 0–1.
hexstring—Current colour as lowercase hex.
setHsva(next: Hsva, commit?: boolean) => void—Set the colour; commit also fires onValueCommit.
commit() => void—Fire onValueCommit with the current colour.
alphaboolean—Whether alpha is enabled.
disabledboolean—Whether the picker is disabled.