npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-color-swatch.json --yesColor swatch
ProOne 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.
What an agent sees
- ColorSwatchGroupA named row of colour pills of which one is chosen
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>
);
}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.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-color-swatch.json --yesAdd the Goop Color swatch to this project. The install steps are at https://goop.so/docs/install.mdUsage
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
| Option | Type | What it does |
|---|---|---|
| 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 |
| Part | What it is |
|---|---|
| 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
| Key | What it does |
|---|---|
| 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
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| 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.