Magoo Component UI logo Magoo Component UI
← Catalog

Colour Picker Input

color-picker-input molecule experimental

A colour field pairing a native swatch, a hex text input and optional quick-pick preset swatches, kept in sync.

Also in: Forms

The width preview needs a screen wider than the chosen width — use a larger device (or a desktop browser) to see the desktop and tablet layouts.

Default
NoPresets

Props

NameTypeReq
label string
value string ✓
presets array

Related components

Related Copy to Clipboard · atom forms/text-field

How to use

behavior.js keeps the native colour input, the hex text field and the preset buttons in sync. Editing the swatch, typing a valid hex (3- or 6-digit, with or without a leading #), or clicking a preset normalizes the value, writes it to data-value on the root, updates the other controls (without clobbering the field the user is actively typing in), and dispatches a bubbling "color:change" CustomEvent with { value }. On blur the hex field snaps back to the canonical value if left mid-edit or invalid. All listeners are removed on cleanup.

Use cases

forminput WCAG AA SEO 20 dir: both ai-generated