color-picker-popup
#existingsourceA compact colour chooser. Use it for brand / theme / label colour entry where a curated palette covers most needs but a custom hex must still be possible. It pairs a preset swatch grid with a hex field and a live preview; Enter commits, Escape closes, focus is trapped while open and restored on close.
When to use
- Brand or theme colour selection from a curated palette
- Tag / label colour assignment with an occasional custom value
- Any surface that previously hand-rolled a colour overlay
When not to use
- Full gradient / alpha authoring — needs a richer colour tool
- A fixed, non-custom set of choices — use a swatch radio group
- Inline single-field entry — use the ColorInput primitive
Accessibility
Role: dialog
- Escape — Close the picker
- Enter — Commit the selected colour
- Tab — Cycle focus within the picker (focus is trapped)
Screen reader: The panel is role=dialog aria-modal=true. Swatches form a listbox of options, each labelled with its hex value and carrying aria-selected. The preview is presentational; the hex field is a labelled text input. Focus is trapped and restored to the trigger on close.
Notes: Swatch colour is conveyed by the accessible name (hex), not colour alone, so the grid is usable without colour perception.
Props
| Name | Type | Default | Description |
|---|---|---|---|
value | string | #3B82F6 | Initial selected colour (hex). |
swatches | array | — | Preset hex swatches. Falls back to a built-in palette when empty. |
trigger_label | string | Pick a colour | Label for the button that opens the picker. |
Examples
Brand-colour picker with the default palette.
YAML
type: color-picker-popup
props:
value: '#3B82F6'
trigger_label: Pick a colourConstrained custom palette.
YAML
type: color-picker-popup
props:
value: '#22C55E'
trigger_label: Label colour
swatches:
- '#EF4444'
- '#F59E0B'
- '#22C55E'
- '#3B82F6'
- '#A855F7'
- '#EC4899'