Skip to Content
Data & Media@hacline/ui/color-picker

ColorPicker

Pick colors via a color area, hue slider, text input, or preset swatches.

Usage

Drag the color area and hue slider, or type a CSS color and press Enter. This example edits colors in HSV while format="hex" determines the output format.

Adjusting Opacity

Set a slider's channel to alpha, and inspect the alpha-enabled CSS representation in the color input.

Parts

PartDescription
ColorPickerArea
A surface for two channels, x and y. Its background comes from --color-area-background where gradients draw it, or a ColorPickerAreaCanvas.
ColorPickerAreaCanvas
Paints the area pixel by pixel, for channels no gradient draws, like OKLCH's chroma by lightness. Colors outside the gamut stay transparent.
ColorPickerAreaThumb
The area's thumb: a slider screen readers hear as both channels.
ColorPickerChannelInput
A number input for one channel, in the units people read it in.
ColorPickerEyeDropper
A button that picks a color from the screen, where the browser can. Elsewhere it's disabled, with data-unsupported.
ColorPickerInput
A text input that reads any CSS color on Enter or blur. Text that isn't one goes back to the value.
ColorPickerSlider
A track for one channel, drawn by --color-slider-background.
ColorPickerSliderThumb
The slider's thumb, at --color-slider-thumb-position.
ColorPickerSwatch
The color itself, as --color-picker-color, named for screen readers.
ColorPickerSwatches
A list of preset colors. Arrow keys move between them.
ColorPickerSwatchItem
A preset color, as --color-picker-color. Pressing it sets the value.

Props

Prop

Type

View UI SDK parts and state attributes.