# Color Picker (Lumen Halo): prompt.md (v1.1.0)

- id: `lumen-color-picker` · version 1.1.0 · component · pro (All-Access)
- category: Inputs
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/lumen-color-picker`
- npm dependencies: none
- registry dependencies: utils, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-color-picker
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

A colour picker in smoked glass: a saturation and brightness field whose thumb is a lit ring, a hue rail whose handle glows in the colour you've picked, a mono hex field and presets as lit cells. Keyboard-first, and read aloud in words ("vivid dark blue"), not hex.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: none beyond React.
- Files: `components/ui/lumen/color-picker.tsx`; shared code: `lib/beautiful-ui/lumen/color.ts`, `lib/beautiful-ui/lumen/sound.ts`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-foundation`.
- Builds: one set of files for both, but its dependencies come in Base UI and Radix builds. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `ColorPicker`, `GradientPicker`, and every exported type.
- CSS: the install merges this item's rules (the registry `css` field) into your global stylesheet, in `@layer components`, and adds the lumen foundation (tokens, keyframes, motion levels) once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--lumen-*` custom properties (`--lumen-accent`, `--lumen-accent-text`, `--lumen-bad`, `--lumen-bad-text`, `--lumen-focus`, `--lumen-good`, `--lumen-good-text`, `--lumen-hairline`, `--lumen-ink`, `--lumen-muted-ink`, `--lumen-series-1`, `--lumen-series-2`, `--lumen-series-3`, `--lumen-series-4`, `--lumen-series-5`, `--lumen-series-6`, `--lumen-warn`, `--lumen-warn-text`); this item's CSS also reads `--lumen-font-mono`, `--lumen-font-sans`, `--lumen-radius-k`. Never add Tailwind colour classes inside the component.

```tsx
import { ColorPicker } from "@/components/ui/lumen/color-picker";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `ColorPicker` | `color-picker` | Field, hue rail, value in any format, eyedropper, contrast and presets. |
| `GradientPicker` | `gradient-picker` | Preview with direction dial, type, stop rail and list, and the stop's colour. |

Style a part with `[data-slot="<slot>"]` selectors or its `className`; keep the attributes when editing.

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `GlassSoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/glass-sound.json`, import from `@/components/beautiful-ui/glass-sound`); `GlassSoundToggle` is its mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/lumen/color-picker.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- color picker, colour picker, brand colour, theme colour, hex input, swatches, palette, customise accent, Lumen
- Letting people choose a brand or accent colour
- Tagging or labelling with a colour (swatches only)

### Not when
- Choosing from a handful of named options: use Toggle Group or Radio Group
- Browsing a whole palette at a glance: use Color Palette

## Mistakes
- Store the hex you get from onValueChange, not the typed text (typing is validated first)
- Check contrast when the colour becomes a text or button colour

## Usage

```tsx
import { ColorPicker } from "@/components/ui/lumen/color-picker";

const [color, setColor] = React.useState("#6b74f5");

<ColorPicker value={color} onValueChange={setColor} swatches={["#6b74f5", "#0e9f8e", "#db3f74"]} contrastWith="#ffffff" />

// Gradients
import { GradientPicker, gradientCss } from "@/components/ui/lumen/color-picker";
<GradientPicker value={gradient} onValueChange={setGradient} />
<div style={{ background: gradientCss(gradient) }} />
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `value / defaultValue` | `string` | `"#6b74f5"` | Hex colour (6 digits). |
| `onValueChange` | `(hex: string) => void` |  | Every change, as 6-digit lowercase hex. |
| `swatches` | `string[]` |  | Preset colours shown as lit cells. |
| `disabled` | `boolean` | `false` | Read-only. |
| `format / defaultFormat / onFormatChange` | `"hex" \| "rgb" \| "hsl" \| "oklch"` | `"hex"` | How the value field reads; any format can be typed in, and the value out is always hex. |
| `contrastWith` | `string` |  | A background to check against: the WCAG ratio and what it's good for, in words. |
| `eyedropper` | `boolean` | `true` | The browser's screen eyedropper where it exists (Chromium today); hidden elsewhere. |
| `GradientPicker value / onValueChange` | `{ type, angle, stops: { id, color, position, opacity }[] }` |  | Linear, radial or conic; a direction dial; stops added on the rail, moved by drag or arrows, removed with Delete. |
| `gradientCss(gradient)` | `(g) => string` |  | The CSS background for a gradient. |

Full docs: https://beautiful-ui.dev/components/lumen-color-picker

## Customising
- Colours: set the `--lumen-*` tokens on `:root`, or on a container with the `lumen-scope` class to retheme one area. Add the `lumen-inherit` class to follow your shadcn palette instead (`--chart-N`, `--destructive`).
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| Arrow keys | Move saturation and brightness (field) or hue (rail) by 1%; a gradient stop by 1%; the direction by 1° |
| Shift + arrows | Move by 10% (15° for direction) |
| Home / End | Hue to the start or end |
| Delete | Remove the focused gradient stop (two always stay) |

## Motion inventory

| Interaction | What moves |
|---|---|
| Drag | The ring grows slightly while held; a quiet tick as the colour changes |
| Presets | Cells lift on hover; the chosen one glows in its colour |

## Accessibility contract (preserve when editing)
- The field and the hue rail are sliders with spoken values in words ("vivid dark blue, saturation 80%, brightness 60%")
- Presets are labelled buttons with a pressed state
- The value field names its format; the contrast readout is words, not just a number
- Gradient stops are sliders read as position, colour and opacity; the direction dial is a slider in degrees

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/lumen-color-picker
```

Pro item: needs the `@beautiful-ui-pro` registry in `components.json` and `BEAUTIFUL_UI_TOKEN` in `.env.local` (https://beautiful-ui.dev/account). Setup: https://beautiful-ui.dev/docs/pro. Your components.json `style` picks the build: radix-*, new-york and default get Radix, base-* gets Base UI.

## Credits
- Built on shadcn/ui conventions (https://ui.shadcn.com)

The lumen foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://beautiful-ui.dev/r/lumen-foundation.json.
