---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Color picker

A painted area and channel sliders that choose one colour, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `ColorPicker`.

## Try it

Open a swatch, drag in the area or along the hue, type a value or pick a preset; the colours are read back, and which picker is open.

The label and the project are our own sample rows; the colours are kept only on this page.

## When to use

- A painted area and channel sliders that choose one colour.
- Also called: color input.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Color picker on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-color-picker.json --yes
```

```text
Add the Goop Color picker to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { useState } from 'react';
import { ColorPicker } from '@/components/ui/goop/color-picker';
import { Field } from '@/components/ui/goop/field';

function CalendarColour() {
  const [colour, setColour] = useState('eb5757');
  return (
    <>
      <div className="flex items-center gap-1.5">
        <ColorPicker label="Calendar colour" value={colour} onValueChange={setColour} />
        <span>Site visits</span>
      </div>
      <Field label="Project colour" orientation="vertical">
        <ColorPicker variant="field" label="Project colour" defaultValue="4cb782" alpha />
      </Field>
    </>
  );
}
```

- Also known as: ColourPicker, ColorInput, Input type="color", SwatchPicker.
- For a label's, a calendar's or a project's colour leave `variant` out (the swatch, `default`) beside its name; in a settings form use `variant="field"` inside a Field. Never a native colour input.
- height, width, padding, gap, corner, border, background, shadow, text, motion: add no class for these.

## API reference

### Options

- `value?: string` — The colour, controlled: hex, `rgb(…)` or `hsl(…)` words.
- `defaultValue?: string` — The first colour, uncontrolled.
- `onValueChange?: (value: string) => void` — Hears the chosen colour as `#rrggbb` (`#rrggbbaa` when it is not opaque) on every change.
- `variant?: 'default' | 'field' = 'default'` — `default`: the swatch, the quiet 36 px button with a 14 px dot; `field`: the text field's 40 px box, the colour and its value.
- `label?: string` — Names the trigger and the panel; "Colour" by default.
- `name?: string` — The form field's name: a hidden field sends the colour as `#rrggbb` (empty while none is chosen).
- `alpha?: boolean = false` — Adds the opacity track.
- `presets?: readonly string[]` — Colours to offer in a row under the field; nine label colours when left out, none when empty.
- `disabled?: boolean = false` — Dims the trigger; nothing opens.
- `className?: string` — Reaches the trigger.
- `open?: boolean` — The panel open, controlled.
- `defaultOpen?: boolean` — The panel open at first.
- `onOpenChange?: (open: boolean) => void` — Hears the panel open and close.
- `container?: HTMLElement | null` — Where the panel is portalled; the end of `<body>` when left out.
- `type?: 'button' | 'submit' | 'reset'`
- `onClick?: (event: MouseEvent) => void`

- State: value (value / defaultValue / onValueChange); open (open / defaultOpen / onOpenChange); drawn by data-focus-visible, data-state=open, data-placeholder

## Keyboard

- Enter / Space: open the panel
- Arrow keys: move the area's thumb 1 % (with Shift 10 %): across for saturation, up and down for brightness
- Home / End: saturation to none or full
- PageUp / PageDown: brightness to full or none
- Enter (in the field): apply the typed value; unreadable words stay, marked invalid
- Arrow keys, Home/End (in the presets): move to the next, the first or the last pill and choose it
- Escape: close the panel and return to the trigger

## Accessibility

- The native element answers the keyboard.
- hover, active: the browser's own (:hover, :active): write nothing
- focus-visible: the attribute data-focus-visible
- checked: the attribute aria-checked
- indeterminate: the attribute aria-checked
- expanded: the attribute data-state=open
- open: the attribute data-state=open
- disabled: the prop disabled
- placeholder-shown: the attribute data-placeholder

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

Shortened to fit: the data-slot values.

## Related

- [Field](/themes/meadow/components/field): A form row that ties one control to its label and its description, as a settings row or a stacked form field.
- [File upload](/themes/meadow/components/file-upload): A drop zone or a button to choose files, for attachments, an import or a photo, with a list of the chosen files.
- [Calendar](/themes/meadow/components/calendar): A month always in view, to choose a date or a range of dates.
- [Date picker](/themes/meadow/components/date-picker): A field that opens a month to choose one date, typed or picked.
