Skip to main content

Color Picker

shadow

Color picker is an element that displays a color palette and allows users to select one of its colors. Displays the hex code of the selected color, which can be easily copied by the user.

Basic usage

When to use

Use wje-color-picker when users need to enter values, choose options, or trigger form-related actions.

When not to use

Do not use it as a decorative element without interaction. Prefer presentational components in that case.

Accessibility

Always provide a label (label/aria-label), keep keyboard support, and surface clear validation feedback.

Best Practices

  • Keep validation rules and error behavior consistent across the entire form.
  • Show loading or disabled states during async operations.
  • Split complex forms into smaller sections with immediate feedback.

Attributes and Properties

inputEditable

DescriptionEnables manual color typing into the input field.
Attributeinput-editable
Typeboolean
Default-

Events

NameDescription
wje-color-picker:selectEmitted when an item is selected.

Methods

parseSwatches

DescriptionNormalizes swatch colors from a string to an array. Supports comma and semicolon separators.
Signature(value: string) => string[]

createSwatches

DescriptionSets the hue.
Signature(node: any) => void

setSliders

DescriptionSets the sliders to the given color.
Signature(color: any) => void

dimension

DescriptionRetrieves the dimensions and position of the color area element relative to the viewport.
Signature() => object

getPointerPosition

DescriptionGets the pointer position in client coordinates (viewport-relative).
Signature(e: any) => \{x: number, y: number\}

setMarkerPosition

DescriptionSets the position of the marker.
Signature(x: any, y: any) => void

clampMarkerPosition

DescriptionClamps marker coordinates to the color area boundaries.
Signature(x: number, y: number) => \{x: number, y: number\}

setColorAtPosition

DescriptionSets the color at the given position.
Signature(x: any, y: any, alpha: any) => *|tinycolor

getHueAreaColor

DescriptionReturns fully saturated and bright color for the current hue. Used as base color for the SV area so neutral grays do not black out the palette.
Signature(color: string) => string

CSS Shadow Parts

NameDescription
anchorThe anchor part of the color picker.
pickerThe main part of the color picker.
markerThe marker part of the color picker.
color-areaThe color area part of the color picker.
hueThe hue slider part of the color picker.
alphaThe alpha slider part of the color picker.
color-previewThe color preview part of the color picker.
inputThe input part of the color picker.

CSS Custom Properties

NameDescription
--wje-color-picker-areaThe color of the color area background.
--wje-color-picker-valueThe value of the color picker input.
--wje-color-picker-swatchThe color of the color swatch button.
--wje-color-picker-sizeThe color of the color marker.
--wje-color-picker-radiusThe color of the color anchor.

Slots

NameDescription
defaultThe card header main content.