Color Picker
<afp-color-picker>
A color picker component with format support (HEX, RGB, HSL, HSV).
Examples #
Shapes #
Use the shape attribute to change the shape of the color picker.
Formats #
Use the format attribute to change the format of the color picker.
Limited formats #
Restrict the available color formats by assigning a limited set of formats to the formats property.
Only the specified formats will be available for selection.
Single-format #
Limit the color picker to one format only by providing a single value in the formats array.
When only one format is available, the format selector is hidden.
Disabled #
Use the disabled attribute to specify whether the color-picker is disabled.
Customization #
Use CSS custom properties to customize the color picker.
Properties
Learn more about properties.
| Name | Description | Reflects | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
disabled
|
Whether the color picker is disabled
Type
boolean
Default
false |
|
||||||||||
shape
|
shape of the color picker
Type
AfpShape
Default
AfpShape.ROUNDED |
|
||||||||||
strategy
|
Positioning strategy for the color picker panel.
Either `absolute` or `fixed`.
Type
AfpStrategy
Default
AfpStrategy.FIXED |
|||||||||||
value
|
The current color value in the selected format
Type
string
Default
'' |
|
||||||||||
format
|
format of the color picker
Type
AfpColorFormat
Default
AfpColorFormat.HEX |
|||||||||||
formats
|
Available color formats to choose from.
If only one format is provided, the format selector is hidden.
Type
AfpColorFormat
Default
[AfpColorFormat.HEX, AfpColorFormat.RGB, AfpColorFormat.HSL, AfpColorFormat.HSV] |
|||||||||||
ariaLabel
arialabel
|
Aria label for the color picker.
This is used for accessibility purposes to provide a text alternative for screen readers.
Type
string
|
|
Events
Learn more about events.
| Name | Return | Description |
|---|---|---|
afp-value-changed
|
string
|
Emitted when the color value changes.
|
Slots
Learn more about slots.
| Name | Description |
|---|---|
default
|
The default slot.
|
Internationalization
Learn more about internationalization.
| Key | Description |
|---|---|
color-picker.aria-label
|
The default `aria-label` text for Color Picker
|
CSS Parts
Learn more about CSS Parts.
| Name | Description | Selector |
|---|---|---|
base
|
The component's base wrapper.
|
::part(base)
|
trigger
|
The part for trigger button.
|
::part(trigger)
|
swatch
|
The part for the color swatch inside the trigger.
|
::part(swatch)
|
popover
|
The part for the popover container.
|
::part(popover)
|
popover-content
|
The part for the popover content.
|
::part(popover-content)
|
gradient-area-wrapper
|
The part for the gradient area wrapper.
|
::part(gradient-area-wrapper)
|
gradient-area
|
The part for the gradient area.
|
::part(gradient-area)
|
gradient-cursor
|
The part for the gradient cursor.
|
::part(gradient-cursor)
|
hue-slider-wrapper
|
The part for the hue slider wrapper.
|
::part(hue-slider-wrapper)
|
hue-slider-label
|
The part for the hue slider label.
|
::part(hue-slider-label)
|
hue-slider
|
The part for the hue slider.
|
::part(hue-slider)
|
color-value-input
|
The part for the color value input field.
|
::part(color-value-input)
|
format-selector-wrapper
|
The part for the format selector wrapper.
|
::part(format-selector-wrapper)
|
CSS Custom Properties
| Name | Description | Default |
|---|---|---|
--afp-color-picker-size
|
The size of the color picker trigger button.
|
--afp-size-s
|
--afp-color-picker-disabled-opacity
|
The opacity of the color picker when disabled.
|
0.5
|
--afp-color-picker-hover-opacity
|
The opacity of the color picker when hovered.
|
0.8
|
--afp-input-label-disabled-opacity
|
The opacity of the input label when disabled.
|
0.5
|
--afp-color-picker-gradient-height
|
The height of the gradient area.
|
200px
|
Dependencies
The component automatically brings in the listed items, including any nested dependencies that may exist.
| Component | CSS Part Prefix |
|---|---|
|
|
popover
- The part for the popover container.
popover-content
- The part for the popover content.
|
|
|
color-value-input
- The part for the color value input field.
|
|
|
button
- The button component.
|
|
|
button-group
- The button-group component.
|
Importing
Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.
import '@afp-design-system/core/dist/components/color-picker/color-picker.js';