Color Picker
UI SDK ColorPicker styled: an area (painted on a canvas in OKLCH, every pixel a colour inside the gamut), hue and alpha sliders, a swatch, a text field for any CSS colour, channel inputs, presets and an eye dropper with a tooltip.
Example
Installation
Usage
In OKLCH the area paints its whole box: inside the gamut each point is its own colour, and past the edge it shows the colour the picker holds there, so the thumb always sits on the colour chosen. A thumb dragged or stepped past the edge stays where it was left, and the value is the closest colour inside.
API reference
ColorPicker
| Prop | Type | Default |
|---|---|---|
labels | Partial<ColorPickerLabels> | – |
Also takes every prop of UI SDK ColorPicker.
ColorPickerArea
ColorPickerAreaCanvas
ColorPickerAreaThumb
ColorPickerSlider
ColorPickerSliderThumb
ColorPickerSwatch
ColorPickerInput
ColorPickerChannelInput
ColorPickerEyeDropper
| Prop | Type | Default |
|---|---|---|
tooltip | ControlTooltipOption | – |
Also takes every prop of UI SDK ColorPickerEyeDropper.
ColorPickerSwatches
ColorPickerSwatchItem
Other exports
colorPickerLabelscreateColorPickerControlleruseColorAreaCanvasuseHeldColorareaChromaMaxareaColorareaPointisOklchInGamutmapToGamutmaxChromaoklchToLinearpaintAreatype ColorPickerLabelstype ColorPickerPropstype ColorChanneltype ColorFormattype ColorPickerControllertype ColorPickerSpacetype ColorPickerValueChangeReasontype Endingtype KeySteptype AreaGamuttype OklchAccessibility
- The area's thumb is a slider screen readers hear as both channels; each slider names its channel; arrow keys step them.
- The text field takes any CSS colour on Enter or blur, and goes back to the value when the text isn't one.
- Presets are one tab stop with arrow keys between them; the eye dropper is an icon button with a tooltip, hidden where unsupported.
Agent actions
Agents find it by its label and set any CSS colour with setValue.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.