API REFERENCE · FORM CONTROLS
<dj-color-picker>
An inline color picker.
It has a saturation and brightness area, a hue slider, an optional opacity slider (alpha), a text field, and optional swatches.
npm install @dojo-ng/color-picker
import "@dojo-ng/color-picker";
Value and format
valueis a color string in theformatyou choose:hex,rgb, orhsl.- The internal model is HSV plus alpha. After you change
format, readingvaluereturns the new representation. - Alpha appears in the output only when the color is translucent or
alphais on. - Named CSS colors, such as
rebeccapurple, are not parsed. dj-change({ value }) fires on every change the user makes, including during a drag. There is no separate input event.
Forms
- The picker is form-associated. It submits the formatted color string under
name.
Swatches
swatchesis an array of color strings or{ value, label }objects.
Dropdowns
- There is no built-in trigger button or popup. Put the picker in a
dj-popupto make a dropdown.
Properties
| Property | Attribute | Type | Default |
|---|---|---|---|
format |
format |
"hex""rgb""hsl" |
"hex" |
alpha |
alpha reflected |
boolean |
false |
swatches |
Property only | Swatch[] |
[] |
label |
label |
string |
None |
name |
name reflected |
string |
None |
disabled |
disabled reflected |
boolean |
false |
get |
get |
string |
None |
Events
| Event | Description |
|---|---|
dj-change | { value } |
CSS parts
Style these with dj-color-picker::part(name).
areathumbhuealphainputswatchesswatchpickerlabel
CSS custom properties
| Property | Default | Description |
|---|---|---|
--dj-color-picker-width | 240px | Overall width of the inline panel. |
Methods
checkValidity(): booleanreportValidity(): boolean
Types
The types that the properties above use, as they are declared in the source.
Swatch
export type Swatch = string | { value: string; label?: string };