Color input component.
The user picks a color with the HSV saturation/value canvas, the hue slider and the optional alpha slider. The user can also type a color string: hex, rgb(a), hsl(a) or a named CSS color.
The component supports pre-defined swatches and the native EyeDropper API,
where the browser provides one. The anchor is a trigger button
(mode="default") or an editable text field (mode="input").
- Element
-
igc-color-picker
- Slots
-
value-missing— Renders content when the required validation fails. -
custom-error— Renders content when setCustomValidity(message) is set. -
invalid— Renders content when the component is in invalid state (validity.valid = false). -
helper-text— Renders content below the picker.
- CSS Parts
-
color-picker— The wrapper of the anchor, the label and the helper text. -
anchor— The trigger element that opens the picker (the button in default mode, or the swatch prefix in input mode). -
empty— Applied alongside `anchor` when no color value is set, rendering a checkered background. -
input-mode— Added to the anchor part in input mode. -
label— The label rendered after the anchor in default mode. -
picker— The popover container holding the canvas, sliders, inputs and swatches. -
picker-canvas— The saturation and value canvas. -
marker— The marker on the canvas that shows the saturation and value. -
dragging— Added to the marker part while the user drags it. -
main-row— The row containing the hue slider and the copy/eyedropper buttons. -
alpha-row— The row containing the alpha slider and input, rendered when `show-alpha` is set. -
inputs-row— The row containing the format select and the color value input. -
buttons— The wrapper around the copy and eyedropper buttons. -
hue— The hue slider. -
alpha— The alpha slider. -
alpha-input— The input of the alpha value, rendered when `show-alpha` is set. -
copy— The button that copies the current color value to the clipboard. -
eye-dropper— The button that activates the EyeDropper API. -
format-select— The select control used to switch the color string format. -
swatches— The container of the pre-defined color swatches. -
swatch— An individual color swatch button.
Properties
Section titled "Properties"disabled
Section titled "disabled"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Whether the control is disabled. A disabled control is not validated, and the form does not submit its value.
disabled: boolean Defined in src/internals/mixins/forms/types.ts:35
format
Section titled "format"The color format of the string value.
A format change renders value in the new notation. The color does not
change, so the component emits no igcInput or igcChange.
format: ColorFormat = 'hex' hideFormats
Section titled "hideFormats"Whether the format select is hidden.
hideFormats: boolean = false invalid
Section titled "invalid"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Whether the control shows the invalid state. It changes only the visual state, not the validity.
invalid: boolean Defined in src/internals/mixins/forms/types.ts:43
Optional label
Section titled "label"The label of the component.
In mode="input" the component forwards the label to the anchor input.
In mode="default" it renders the label as a separate element.
label: string The mode of the color picker.
In "default" mode the anchor is a trigger button. In "input" mode the
anchor is an editable text field with a color swatch prefix. The prefix
also opens the picker.
mode: ColorPickerMode = 'default' Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
The name of the control, submitted with the form data.
name: string Defined in src/internals/mixins/forms/types.ts:49
Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Whether the component is open.
open: boolean = false Defined in src/internals/bases/combo-box.ts:50
scrollStrategy
Section titled "scrollStrategy"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
The behavior of the component when a parent container scrolls.
If the value is hide, the component hides while the anchor is fully out
of view. hide is the default value.
If the value is scroll, the component stays visible and anchored.
If the value is close, the component closes on each scroll.
scrollStrategy: PopoverScrollStrategy = 'hide' Defined in src/internals/bases/combo-box.ts:65
showAlpha
Section titled "showAlpha"Whether to show the alpha slider and input.
showAlpha: boolean = false swatches
Section titled "swatches"Pre-defined color strings. The component renders them as clickable swatches below the picker controls. A click on a swatch sets its color as the value.
swatches: string[] = [] tagName
Section titled "tagName"The tagName read-only property of the Element interface returns the tag name of the element on which it's called.
tagName: "igc-color-picker" = 'igc-color-picker' Accessors
Section titled "Accessors"defaultValue
Section titled "defaultValue"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
get defaultValue(): any Defined in src/internals/mixins/forms/types.ts:158
The default value of the control. A form reset restores the value to it.
While the value is unchanged since the start or the last form reset, a new
default also sets the value. The value attribute also sets it.
set defaultValue(value: unknown): void Defined in src/internals/mixins/forms/types.ts:158
Parameters
- value:
unknown
Returns void
Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
The form that the control is associated with, or null.
get form(): HTMLFormElement | null Defined in src/internals/mixins/forms/types.ts:52
Returns HTMLFormElement | null
required
Section titled "required"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
get required(): any Defined in src/internals/mixins/forms/types.ts:188
Whether the control is required. A required control that has no value, or is not checked, fails validation.
set required(value: boolean): void Defined in src/internals/mixins/forms/types.ts:188
Parameters
- value:
boolean
Returns void
validationMessage
Section titled "validationMessage"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
The validation message of the control. It is empty when the control is valid.
get validationMessage(): string Defined in src/internals/mixins/forms/types.ts:61
Returns string
validity
Section titled "validity"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
The validity state of the control.
get validity(): ValidityState Defined in src/internals/mixins/forms/types.ts:55
Returns ValidityState
value
Section titled "value"get value(): any The value of the component as a CSS color string. Accepts hex, rgb(a), hsl(a) and named colors.
An empty, whitespace-only or invalid string clears the value.
set value(value: string): void Defined in src/components/color-picker/color-picker.ts:252
Parameters
- value:
string
Returns void
willValidate
Section titled "willValidate"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Whether the control is a candidate for constraint validation.
get willValidate(): boolean Defined in src/internals/mixins/forms/types.ts:64
Returns boolean
Methods
Section titled "Methods"Removes focus from the color picker.
blur(): void Defined in src/components/color-picker/color-picker.ts:701
Returns void
checkValidity
Section titled "checkValidity"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Checks validity and emits invalid when the control is invalid. Returns
true when the control is valid.
checkValidity(): boolean Defined in src/internals/mixins/forms/types.ts:134
Returns boolean
focus
Section titled "focus"Sets focus on the color picker.
focus(options: FocusOptions): void Defined in src/components/color-picker/color-picker.ts:694
Parameters
- options:
FocusOptions
Returns void
Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Closes the component. It does not emit events. The promise resolves to
false when the component is already closed, or when a later call
replaces this one.
hide(): Promise<boolean> Defined in src/internals/bases/combo-box.ts:135
Returns Promise<boolean>
reportValidity
Section titled "reportValidity"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Checks validity. As for a native control, an invalid control emits
invalid and takes the focus. It shows its own validation messages, not
the message of the browser. Returns true when the control is valid.
reportValidity(): boolean Defined in src/internals/mixins/forms/types.ts:141
Returns boolean
setCustomValidity
Section titled "setCustomValidity"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Sets a custom validation message. The control is invalid while the message is not empty. An empty string removes the custom error.
setCustomValidity(message: string): void Defined in src/internals/mixins/forms/types.ts:147
Parameters
- message:
string
Returns void
Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Opens the component. It does not emit events. The promise resolves to
false when the component is already open, or when a later call replaces
this one.
show(): Promise<boolean> Defined in src/internals/bases/combo-box.ts:126
Returns Promise<boolean>
toggle
Section titled "toggle"Inherited from: I18nMixin( FormAssociatedRequiredMixin( EventEmitterMixin< IgcColorPickerComponentEventMap, typeof IgcBaseComboBoxComponent >(IgcBaseComboBoxComponent) ), i18n )
Opens the component when it is closed, and closes it when it is open. It
does not emit events. The promise resolves to true when the state
changes.
toggle(): Promise<boolean> Defined in src/internals/bases/combo-box.ts:144