Color picker
color-pickerA full colour editor: a saturation and brightness area, hue and opacity rails, a hex field, numeric channels, screen sampling and preset swatches — all composed from parts, opened from a trigger chip that previews the value.
import {
ColorPicker,
ColorPickerAlpha,
ColorPickerArea,
ColorPickerChannels,
ColorPickerContent,
ColorPickerEyeDropper,
ColorPickerHexInput,
ColorPickerHue,
ColorPickerPreset,
ColorPickerPresets,
ColorPickerSwatch,
ColorPickerTrigger,
} from "@/components/forme/color-picker/color-picker";
const PRESETS = [
{ value: "#3478f6", label: "Blue" },
{ value: "#8b5cf6", label: "Violet" },
{ value: "#ec4899", label: "Pink" },
{ value: "#ef4444", label: "Red" },
{ value: "#f59e0b", label: "Amber" },
{ value: "#10b981", label: "Emerald" },
];
export function ColorPickerDemo() {
return (
<div className="flex flex-col gap-6">
<ColorPicker defaultValue="#ec4899" label="Accent colour">
<ColorPickerTrigger />
<ColorPickerContent>
<ColorPickerArea />
<div className="flex items-center gap-2">
<ColorPickerHue />
<ColorPickerAlpha />
<ColorPickerEyeDropper />
</div>
<div className="flex items-center gap-2">
<ColorPickerSwatch className="size-8" />
<ColorPickerHexInput />
</div>
<ColorPickerChannels />
<ColorPickerPresets>
{PRESETS.map((preset) => (
<ColorPickerPreset key={preset.value} value={preset.value} label={preset.label} />
))}
</ColorPickerPresets>
</ColorPickerContent>
</ColorPicker>
<ColorPicker defaultValue="#10b981" alpha={false} label="Opaque colour">
<ColorPickerTrigger />
<ColorPickerContent>
<ColorPickerArea />
<div className="flex items-center gap-2">
<ColorPickerHue />
<ColorPickerEyeDropper />
</div>
<div className="flex items-center gap-2">
<ColorPickerSwatch className="size-8" />
<ColorPickerHexInput />
</div>
</ColorPickerContent>
</ColorPicker>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
Usage
import {
ColorPicker,
ColorPickerAlpha,
ColorPickerArea,
ColorPickerContent,
ColorPickerHexInput,
ColorPickerHue,
ColorPickerTrigger,
} from "@/components/forme/color-picker/color-picker";
<ColorPicker defaultValue="#ec4899" label="Accent colour">
<ColorPickerTrigger />
<ColorPickerContent>
<ColorPickerArea />
<ColorPickerHue />
<ColorPickerAlpha />
<ColorPickerHexInput />
</ColorPickerContent>
</ColorPicker>When to use
Reach for it
- Picking a colour rather than choosing one from a fixed palette — for a short list, a
ColorSelectoris faster to use and to scan. onValueCommitfor anything that saves or re-renders the page, so a drag is one update instead of hundreds.- A duplicate of the current value beside the editor, so the choice can be read back after the panel closes.
Use something else
alphawhen the value ends up in a place that cannot render transparency — an email, a token with no alpha channel — since the last two hex digits will be silently dropped.- A picker for a decision the design already made; a preset row alone is less work for everyone.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
ColorPicker
A colour picker: a trigger chip that opens a saturation/brightness area, a hue rail, an opacity rail, a hex field and optional numeric channels.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Controlled hex colour, #rgb, #rrggbb or #rrggbbaa. |
defaultValue | string | "#3478f6" | The colour when uncontrolled. Default: #3478f6 |
onValueChange | (value: string) => void | — | Fires on every change while dragging or typing, as a lowercase hex. |
onValueCommit | (value: string) => void | — | Fires once an interaction settles: pointer release, key, preset or field commit. |
alpha | boolean | true | Allow transparency. When false the value is always opaque. Default true. |
name | string | — | Submits the hex value with a form under this name. |
open | boolean | — | Controlled open state for the trigger and its panel. |
defaultOpen | boolean | false | Whether the panel starts open when uncontrolled. Default false |
onOpenChange | (open: boolean) => void | — | Called when the panel opens or closes. |
label | string | — | Accessible name for the picker as a whole. |
disabled | boolean | false |
Also takes every prop of <div> attributes.
ColorPickerArea
Saturation across, brightness up. The thumb is a 2D slider: one control, two values, stepping with the arrows and jumping with Home/End on saturation.
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | "Saturation and brightness" | Accessible name for the 2D control. Default "Saturation and brightness" |
Also takes every prop of <div> attributes.
ColorPickerHue
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | "Hue" | Accessible name for the hue rail. Default "Hue" |
className | string | — |
ColorPickerAlpha
Renders nothing when the picker has alpha={false}.
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | "Opacity" | Accessible name for the opacity rail. Default "Opacity" |
className | string | — |
ColorPickerChannels
Numeric RGB or HSL fields, plus opacity when alpha is enabled. Arrow keys nudge.
| Prop | Type | Default | Description |
|---|---|---|---|
format | "rgb" | "hsl" | "rgb" | Which channels to edit. Default "rgb" |
Also takes every prop of <div> attributes.
ColorPickerEyeDropper
Samples a colour from anywhere on screen.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — |
Also takes every prop of <button> attributes.
ColorPickerPreset
| Prop | Type | Default | Description |
|---|---|---|---|
value* | string | — | The hex this preset applies. |
label | string | — | Accessible colour name. Defaults to the hex. |
Also takes every prop of <button> attributes.
ColorPickerTrigger
Opens the panel. Its colour chip previews the value the panel edits.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Replaces the hex label beside the chip. |
Also takes every prop of <button> attributes.
The other parts
ColorPickerSwatchTakes<span>attributesColorPickerHexInputTakes<input>attributesColorPickerPresetsTakes<div>attributesColorPickerContentTakes Base UIPopover.PopupandPick<ComponentProps<typeof PopoverPrimitive.Positioner>, "side" | "sideOffset" | "align">
Accessibility
- The area is a 2D slider with one accessible name and a value text naming both axes, because two separate sliders would not say they belong together.
- Every rail takes arrows, Page Up and Page Down, Home and End; the loupe and the thumb's white ring are decorative and hidden from the tree.
- The panel is a popover dialog: it takes focus on open, closes on Escape and on an outside press, and returns focus to the trigger.
Motion
- The thumb glides on a spring while dragging so the control feels like it has mass, and the loupe lifts with a small overshoot to say it is picked up.
- The preset ring hops along an arc between swatches; a straight spring would pass through the swatch in between.
- Reduced motion keeps every position change and drops the lift, the hop and the entrance.
Responsive behaviour
- The trigger is a fit-content chip, so it sits in a form row without stretching; the panel is 288px and will not fit beside a narrow control, so place it where it has room below.
- The numeric channel fields share the row evenly and stay legible down to four of them.
Related
Color selector
A row of colour swatches where exactly one is chosen. Real radio inputs inside a fieldset, so forms, required state, arrow keys and screen-reader grouping all work natively, and one selection ring hops between swatches.
inputs

Calendar
A month grid for a single date or a range, with no date library. Full WAI-ARIA keyboard support, month and year pickers, min, max and disabled days, a range that previews under the pointer or the keyboard, and a fixed six-week height so nothing below it jumps.
inputsDate Range Picker
A button that opens a calendar for a date range: the range said in words on the trigger, a day count, Clear and Done, and optional presets. Ranges can refuse disabled days inside them, for bookings.
inputs