Color Picker
Material Design 3 color picker web component (preset swatch grid + native color input).
- 4.7 KB gzipped
- @lit-material/color-picker 1.8.0
- Renders on the server
Example
Color Picker
A swatch trigger that opens a preset color grid plus a native <input type="color">
for arbitrary values.
Markup
<lit-material-color-picker label="Accent color" value="#6750a4"></lit-material-color-picker>
No value
Install
npm install @lit-material/color-picker @lit-material/tokens
import "@lit-material/color-picker";
Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide
API
<lit-material-color-picker>
Material Design 3-styled color picker — a swatch trigger that opens a
popover (Popover API, the same popover="auto" foundation select/
date-picker/search use for their own popup surfaces) holding a preset
color grid plus a native <input type="color"> for arbitrary values —
leaning on the platform's own color picker rather than reimplementing a
hue/saturation canvas from scratch.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
value | value | string | "" | > |
label | label | string | "" | > |
name | name | string | "" | > |
disabled | disabled | boolean | false | > |
required | required | boolean | false | > |
open | open | boolean | false | > |
form | form | string | undefined | none | > |
presets | presets | readonly string[] | [ "#6750a4", "#625b71", "#7d5260", "#b3261e", "#006874", "#386a20", "#0061a4", "#984061", "#7c5800", "#1a1c18", ] | > |
Events
| Event | Description |
|---|---|
change | Fires when the committed color value changes via user interaction. |
CSS parts
| Part | Description |
|---|---|
trigger | The button that shows the current color and opens the panel. |
swatch | The color swatch inside the trigger. |
label | The label text next to the trigger swatch. |
panel | The popover panel surface. |
preset | Each preset swatch button. |
custom-input | The native <input type="color">. |
hex-input | The text input mirroring the hex value. |