Forms Form-associated
ColorPicker <pm-color-picker>
Colour picker: a swatch + hex field with a popup (or inline panel) holding a saturation/brightness area, hue and optional alpha sliders, preset swatches and the EyeDropper where supported.
Sizes
Set with the size attribute; controls keep touch-sized targets on phones.
size="xs"size="sm"size="md"size="lg"size="xl"States
Each state is one attribute.
DisabledRead-onlyRequiredErrorWith a hintOverview
Value is "#rrggbb" ("#rrggbbaa" with alpha) and is submitted with forms. Keys on the area: arrows ±1%, Shift ±10%.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
mobile | boolean | — | Native mobile pattern on phones; not set means as the ancestors say, false opts out. |
alpha | boolean | false | Allow transparency (adds an alpha slider; value becomes #rrggbbaa when not opaque). |
inline | boolean | false | Render the panel inline instead of in a popup. |
swatches | string | string[] | — | Preset colours: comma-separated or a JSON array. |
placeholder | string | — | Hint text shown while empty (not a replacement for label). |
open | boolean | false | The popup is open. Setting it opens or closes it. |
name | string | — | Form field name: the value is submitted under it. |
value | string | — | Current value (submitted with the form). |
label | string | — | Visible label (required for accessibility; use hide-label to visually hide it). |
hint | string | — | Help text under the field, linked to it for screen readers. |
error | string | — | Custom error message. Setting it marks the control invalid. |
size | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | — | Control size. |
required | boolean | false | The form cannot be submitted until this has a value. |
disabled | boolean | false | Not interactive and not submitted. |
readonly | boolean | false | Focusable and submitted, but not editable. |
hide-labelprop: hideLabel | boolean | false | Hide the label visually; it stays the accessible name. |
Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.
Events
| Event | React / Svelte prop | Description |
|---|---|---|
pm-open | onPmOpen | The popup opened. |
pm-close | onPmClose | The popup closed. |
pm-input | onPmInput | On every value change while editing. |
pm-change | onPmChange | When the value is committed. |
Methods
show(), hide(), toggle(), close(), checkValidity(), reportValidity(), validate(), focus()