---
title: "Color Picker"
description: "A color pick that opens from a field or a swatch. The popup holds a color area, a hue slider, a hex field, and an eyedropper."
url: https://gelatinui.com/components/color-picker
markdown_url: https://gelatinui.com/components/color-picker.md
access: free
install: "npx shadcn@latest add @gelatin-ui/color-picker"
registry_item: https://gelatinui.com/r/color-picker.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Color Picker

> A color pick that opens from a field or a swatch. The popup holds a color area, a hue slider, a hex field, and an eyedropper.

Page: https://gelatinui.com/components/color-picker

## When to use it

Best for: Pick one color from a field or a swatch, in a popover with an area, hue slider, and hex field.

- Use it when people pick any color, not a color from a short list.
- Use `ColorPickerTrigger` with `variant="field"` in a form, or `variant="swatch"` in a toolbar.
- Use `ColorPickerContent` with no children to get the default editor.
- Pass your own children to `ColorPickerContent` for channel sliders or an alpha slider.
- Put the color parts directly in `ColorPicker` for an inline editor with no popover.

## When not to use it

- To only show a color, use a [Color Swatch](https://gelatinui.com/components/color-swatch.md).
- To type a hex value with no popover, use a [Color Field](https://gelatinui.com/components/color-field.md).
- To change one channel of a color, use a [Color Slider](https://gelatinui.com/components/color-slider.md).

## Notes for agents

- `onValueChange` always gets a `Color` object, not a string. Call `color.toString("hex")` for text.
- `ColorPicker` renders no element. It wraps a React Aria color state around a Base UI Popover root.
- Color parts inside `ColorPicker` read and set its color with no props.
- Name the trigger with `aria-labelledby`, which keeps the color in the name. `aria-label` replaces the name.
- `ColorPickerEyeDropper` renders nothing where the browser has no EyeDropper API.
- Pass `onPickError` to `ColorPickerEyeDropper`. With no handler, the error goes to the nearest error boundary.
- `children` of the root can be a function of `{ color }`. Read a Popover payload in the content instead.

## Anatomy

```text
ColorPicker
├─ ColorPickerTrigger (0..n)
├─ ColorPickerContent (0..n)
└─ ColorPickerEyeDropper (0..n)
```

## API reference

### ColorPicker

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string \| Color` |  | The current value (controlled). |
| `defaultValue` | `string \| Color` |  | The default value (uncontrolled). |
| `slot` | `string \| null` |  | A slot name for the component. Slots allow the component to receive props from a parent component. An explicit `null` value indicates that the local props completely override all props received from a parent. |
| `onValueChange` | `function` |  | Runs on each change, with the new value and the Base UI change details. |
| `children` | `ColorPickerPrimitiveProps["children"]` |  | The trigger, the content, or inline color components. A function gets `{ color }`. |
| `labels` | `Partial<typeof COLOR_PICKER_LABELS>` |  | The words (`COLOR_PICKER_LABELS`), to translate them. Keep the object stable. |

Also takes every prop of Base UI `Popover.Root`: https://base-ui.com/react/components/popover

### ColorPickerTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `variant` | `"field" \| "swatch"` | "field" | `field` (default): a field with a swatch, the hex value, and a chevron. `swatch`: a 32px outline icon button with a 24px swatch. It has one size. |
| `size` | `ControlSizeAtLeastSm` | "default" | The height of the field: `sm` 28, `default` 32, `lg` 36. |

Also takes every prop of Base UI `Popover.Trigger`: https://base-ui.com/react/components/popover

### ColorPickerContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `arrow` | `boolean` |  | Show an arrow that points at the trigger. The gap grows from 4px to 8px. |
| `backdrop` | `boolean` |  | Put a clear layer under the popup (Base UI `Popover.Backdrop`), for example to dim it. |
| `showCloseButton` | `boolean` |  | Show a close button (a 24px ghost icon button) 10px from the top and the end. |
| `padding` | `"default" \| "none" \| "tight"` |  | `default`: radius 14, 12px padding and 10px between the parts, 288px wide. `tight`: 4px padding and 4px between the parts, as wide as the content: a row of 28px actions (a plain Toolbar) with the 4px inset of the bar recipe, 38px high (the selection pill of the Quote Reply). `none`: no padding and no gap, as wide as the content: a panel that lays out its own parts edge to edge (a head with a rule, a scroll box, a docked composer: the Chat Popup). Give it a width and a height with layout classes; the body fills that height. |
| `portalProps` | `Omit` |  | Other Base UI props of the inner parts. A `className` here adds to the component classes. |
| `positionerProps` | `PopupPartProps` |  |  |
| `backdropProps` | `PopupPartProps<PopoverBackdropProps>` |  |  |
| `arrowProps` | `PopupPartProps<PopoverArrowProps>` |  |  |
| `closeButtonProps` | `PopupPartProps` |  |  |
| `closeLabel` | `string` |  | The accessible name of the close button. Translate it with the page. |

Also takes every prop of Base UI `Popover.Popup`: https://base-ui.com/react/components/popover

### ColorPickerEyeDropper

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `children` | `ReactNode` |  | The icon. Default: a pipette. |
| `onPickError` | `function` |  | Runs when the browser EyeDropper fails (not on a cancel). Show the user a message here. With no handler, the error goes to the nearest error boundary. |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| ColorPicker | `color-picker` |  |  |  |
| ColorPickerTrigger | `color-picker-trigger` |  |  |  |
| ColorPickerContent | `color-picker-content` |  |  |  |
| ColorPickerEyeDropper | `color-picker-eye-dropper` |  |  |  |

## Usage

`ColorPicker` renders no element. It shares one color between the trigger and the popup. `onValueChange` gets a `Color` object, not a string.

```tsx title="fill-color.tsx"
import { ColorPicker, ColorPickerContent, ColorPickerTrigger } from "@/components/ui/color-picker";

export function FillColor() {
  return (
    <ColorPicker defaultValue="#2B7FD9">
      <ColorPickerTrigger aria-label="Fill" />
      <ColorPickerContent />
    </ColorPicker>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/color-picker
```

It adds 52 registry items: 47 files, 7077 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `clsx`, `motion`, `react-aria-components`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Animated Chevrons Up Down Icon](https://gelatinui.com/components/animated-chevrons-up-down-icon.md)
- [Button](https://gelatinui.com/components/button.md)
- [Color Area](https://gelatinui.com/components/color-area.md)
- [Color Field](https://gelatinui.com/components/color-field.md)
- [Color Slider](https://gelatinui.com/components/color-slider.md)
- [Color Swatch](https://gelatinui.com/components/color-swatch.md)
- [Popover](https://gelatinui.com/components/popover.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Color Area](https://gelatinui.com/components/color-area.md)
- [Color Slider](https://gelatinui.com/components/color-slider.md)
- [Color Field](https://gelatinui.com/components/color-field.md)
- [Color Swatch](https://gelatinui.com/components/color-swatch.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter, Space | On `ColorPickerTrigger`: opens the popover. |
| Escape | Closes the popover. |
| Arrow keys | `ColorArea` thumb: moves the thumb one step on each axis. With Shift, it moves a large step. |
| Arrow keys | `ColorSlider` thumb: moves the thumb one step. With Shift, it moves a large step. |
| Enter | `ColorField`: sets the typed value. |

## Accessibility

Name the trigger with `aria-labelledby`, which keeps the color in the name. `aria-label` replaces the name.

Every control in the popup works with the keyboard, and focus goes back to the trigger on close.

`ColorPickerEyeDropper` renders nothing where the browser has no EyeDropper API.

## Motion

| Part | Motion |
| --- | --- |
| Open | popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) · fades in and scales from 95% |
| Close | popup-exit · 120ms · ease-out (0, 0, 0.2, 1) |
