Skip to content

Color Picker

Color Picker provides a workflow to change color, modify transparency, and save favorite colors.

Overview

Color Picker sliders can be used for general hue shifts, while hexadecimal (Hex) and other channels such as RGB can be used for more exact color choices. The ability to save colors helps keep the user experience more efficient.

Channels and features can be hidden with properties to keep the workflow focused.

Usage

  • Choosing an initial color of an element
  • Changing color or transparency of an element
  • Ability to copy/paste Hex, RGB, HSV, or other values

Sample

Keyboard navigation

KeyFunction
Arrow downWhen focused on the Hex, RGB, or HSV inputs decreases the value by one (1).
Arrow upWhen focused on the Hex, RGB, or HSV inputs increases the value by one (1).
Shift and Arrow downWhen focused on the Hex, RGB, or HSV inputs decreases the value by ten (10).
Shift and Arrow upWhen focused on the Hex, RGB, or HSV inputs increases the value by ten (10).
TabMoves focus to the next focusable element. If the currently focused element is the last element, focus will leave the component.
Tab and ShiftMoves focus to the previous focusable element. If the currently focused element is the first element, focus will leave the component.

API reference

Properties

PropertyAttributeDescriptionTypeDefault
allowEmptyallow-empty
deprecatedUse clearable instead
When present, an empty color (null) will be allowed as a value. When not present, a color value is enforced, and clearing the input or blurring will restore the last valid value.
booleanfalse
alphaChannelalpha-channelWhen present, the component will allow updates to the color's alpha value.booleanfalse
channelsDisabledchannels-disabledWhen present, hides the RGB/HSV channel inputs.booleanfalse
clearableclearableWhen present, an empty color (null) will be allowed as a value. When not present, a color value is enforced, and clearing the input or blurring will restore the last valid value.booleanfalse
disableddisabledWhen present, interaction is prevented and the component is displayed with lower opacity.booleanfalse
fieldDisabledfield-disabledWhen present, hides the color field.booleanfalse
formatformatThe format of value. When "auto", the format will be inferred from value when set."auto" | "hex" | "hexa" | "hsl" | "hsl-css" | "hsla" | "hsla-css" | "hsv" | "hsva" | "rgb" | "rgb-css" | "rgba" | "rgba-css""auto"
hexDisabledhex-disabledWhen present, hides the hex input.booleanfalse
messageOverridesUse this property to override individual strings used by the component.Record<string, unknown>
numberingSystemnumbering-systemSpecifies the Unicode numeral system used by the component for localization."arab" | "arabext" | "latn"
savedDisabledsaved-disabledWhen present, hides the saved colors section.booleanfalse
scalescaleSpecifies the size of the component."l" | "m" | "s""m"
storageIdstorage-idSpecifies the storage ID for colors.string
valuevalueThe component's value, where the value can be a CSS color string, or a RGB, HSL or HSV object. The type will be preserved as the color is updated.(HSL & ObjectWithAlpha) | (HSV & ObjectWithAlpha) | (RGB & ObjectWithAlpha) | HSL | HSV | RGB | string

Styles

NameDescription
--calcite-color-picker-background-colorSpecifies the component's background color.
--calcite-color-picker-border-colorSpecifies the component's border color.
--calcite-color-picker-corner-radiusSpecifies the component's corner radius.
--calcite-color-picker-shadowSpecifies the component's shadow.
--calcite-color-picker-text-colorSpecifies the component's text color.
--calcite-color-picker-input-background-colorSpecifies the component's input background color.
--calcite-color-picker-input-border-colorSpecifies the component's input border color.
--calcite-color-picker-input-text-colorSpecifies the component's input text color.
--calcite-color-picker-input-prefix-background-colorWhen hexDisabled is not true, specifies the component's input prefix background color.
--calcite-color-picker-input-prefix-text-colorWhen hexDisabled is not true, specifies the component's input prefix text color.
--calcite-color-picker-input-suffix-background-colorWhen alphaChannel is true, specifies the component's input suffix background color.
--calcite-color-picker-input-suffix-text-colorWhen alphaChannel is true, specifies the component's input suffix text color.
--calcite-color-picker-tab-border-colorSpecifies the component's tab border color.
--calcite-color-picker-tab-text-colorSpecifies the component's tab text color.
--calcite-color-picker-tab-accent-color-pressSpecifies the component's tab accent color when selected or active.
--calcite-color-picker-swatch-corner-radiusSpecifies the component's swatch corner radius.
--calcite-color-picker-action-text-color-pressSpecifies the component's savedColors action text color when pressed.
--calcite-color-picker-action-text-color-hoverSpecifies the component's savedColors action text color when hovered.
--calcite-color-picker-action-text-colorSpecifies the component's savedColors action text color.

Events

NameDescriptionBehavior
calciteColorPickerChangeFires when the color value has changed.bubblescomposed
calciteColorPickerInputFires as the color value changes. Similar to the calciteColorPickerChange event with the exception of dragging. When dragging the color field or hue slider thumb, this event fires as the thumb is moved.bubblescomposed

Methods

NameDescriptionSignature
componentOnReadyCreate a promise that resolves once component is fully loaded.componentOnReady(): Promise<void>
setFocusSets focus on the component's first focusable element.setFocus(options?: FocusOptions): Promise<void>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.