---
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 swatch

One colour pill, to pick a colour from a row of them or to show one on a menu's trigger, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `ColorSwatch`.

## When to use

- One colour pill, to pick a colour from a row of them or to show one on a menu's trigger.

## 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 swatch 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-swatch.json --yes
```

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

## Usage

```tsx
import { ColorSwatch, ColorSwatchGroup } from '@/components/ui/goop/color-swatch';

const COLOURS = [
  { value: 'sky', label: 'Sky', color: 'blue' },
  { value: 'leaf', label: 'Leaf', color: 'green' },
  { value: 'poppy', label: 'Poppy', color: 'red' },
  { value: 'stone', label: 'Stone', color: 'grey' },
  { value: 'honey', label: 'Honey', color: 'amber' },
  { value: 'dusk', label: 'Dusk', color: 'indigo' },
  { value: 'rose', label: 'Rose', color: 'pink' },
] as const;

function SiteVisitsColour() {
  return (
    <ColorSwatchGroup aria-label="Site visits colour" name="colour" defaultValue="leaf">
      {COLOURS.map((colour) => (
        <ColorSwatch key={colour.value} {...colour} />
      ))}
    </ColorSwatchGroup>
  );
}
```

- Fits: settings, record: field.
- height, width, gap, corner, border, background, text, motion: add no class for these.

## API reference

### Options

- `value: string` — The value the group reports, and sends with its form, when this pill is chosen.
- `color: 'blue' | 'green' | 'red' | 'grey' | 'cyan' | 'amber' | 'indigo' | 'pink'` — The pill's colour: a hue word (`blue`, `green`, `red`, `grey`, `cyan`, `amber`, `indigo`, `pink`).
- `label: string` — The colour's words, which name the pill for a screen reader ("Moss"; alone, "Site colour: Moss").
- `variant?: 'default' | 'dot' = 'default'` — `default` (left out): the 20 by 10 px colour pill.
- `type?: 'button' | 'submit' | 'reset'`
- `onClick?: (event: MouseEvent) => void`
- `disabled?: boolean`

### Parts

- `ColorSwatchGroup` — A named row of colour pills of which one is chosen; value?: string — The chosen pill's value, for a group its caller holds (with `onValueChange`); defaultValue?: string — The pill chosen at first render, for a group that holds its own choice; onValueChange?: (value: string) => void — Called with a pill's value whenever a person chooses it; name?: string — The form field's name: the chosen value goes with the form it sits in (empty while none is chosen); disabled?: boolean = false — Every pill off: none takes the focus, a press or a key

- data-slot values (to select a part by): color-swatch, color-swatch-dot, color-swatch-group

## Keyboard

- Tab: reach the chosen pill (the first live pill when none is chosen); the row is one tab stop
- ArrowRight / ArrowDown: move to the next live pill and choose it, wrapping at the end
- ArrowLeft / ArrowUp: move to the previous live pill and choose it, wrapping at the start
- Home / End: move to the first or the last live pill and choose it
- Enter / Space: choose the focused pill

## 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

## 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.

## Related

- [Comment thread](/themes/meadow/components/comment-thread): A record's discussion: replies, reactions, resolve.
- [Draft email card](/themes/meadow/components/draft-email-card): An email an assistant drafted, ready to send, for a page's column or a chat's reply.
- [Event proposal card](/themes/meadow/components/event-proposal-card): A calendar event an assistant proposes, ready to add, for a page's column or a chat's reply.
- [Inline edit](/themes/meadow/components/inline-edit): Words that read as plain text and become an editable field in place, such as a record's title or a property's value.
