Homelogologo
Sponsor

Color Picker

A component that allows users to select a color from a spectrum or predefined swatches.

Usage

A feature-rich compound component that provides a complete interface for color selection, including color areas, sliders, and swatches.

import { ColorPicker, Swatch, Surface, Portal, parseColor, } from "@elemnts-ui/react"; const color = parseColor("#eb5e41"); <ColorPicker defaultValue={color}> <ColorPicker.Control> <ColorPicker.Trigger> <ColorPicker.ValueSwatch asChild> <Swatch size="sm" /> </ColorPicker.ValueSwatch> </ColorPicker.Trigger> </ColorPicker.Control> <Portal> <ColorPicker.Positioner> <ColorPicker.Content> <Surface p="8"> <ColorPicker.Area> <ColorPicker.AreaBackground> <ColorPicker.AreaThumb /> </ColorPicker.AreaBackground> </ColorPicker.Area> <ColorPicker.ChannelSlider channel="hue"> <ColorPicker.ChannelSliderTrack> <ColorPicker.ChannelSliderThumb /> </ColorPicker.ChannelSliderTrack> </ColorPicker.ChannelSlider> </Surface> </ColorPicker.Content> </ColorPicker.Positioner> </Portal> </ColorPicker>;

Swatch Grid

Use the ColorPicker.SwatchGroup to provide a list of predefined colors for the user to choose from.

Area Channels

Remap the color area to different channels using the xChannel and yChannel props.

Alpha Slider

Use the alpha channel with a ColorPicker.TransparencyGrid to allow users to adjust the opacity of a color.

RGB Channel Sliders

Display multiple channel sliders within a ColorPicker.View to allow explicit editing of each color channel.

API Reference

ColorPicker

Root element for the color picker.

PropTypeDefault
closeOnSelectbooleanfalse
defaultFormatColorFormat"rgba"
defaultOpenboolean-
defaultValueColor#000000
disabledboolean-
formatColorFormat-
hideModeHideMode"display-none"
idstring-
idsPartial<ColorPickerIds>-
immediateboolean-
initialFocusEl() => HTMLElement | null-
inlineboolean-
invalidboolean-
lazyMountbooleanfalse
namestring-
onExitCompleteVoidFunction-
onFocusOutside(event: FocusOutsideEvent) => void-
onFormatChange(details: FormatChangeDetails) => void-
onInteractOutside(event: InteractOutsideEvent) => void-
onOpenChange(details: OpenChangeDetails) => void-
onPointerDownOutside(event: PointerDownOutsideEvent) => void-
onValueChange(details: ValueChangeDetails) => void-
onValueChangeEnd(details: ValueChangeDetails) => void-
openboolean-
openAutoFocusbooleantrue
positioningPositioningOptions-
presentboolean-
readOnlyboolean-
requiredboolean-
skipAnimationOnMountbooleanfalse
unmountOnExitbooleanfalse
valueColor-
asChildbooleanfalse

ColorPickerRootProvider

Provides a color picker state machine created with useColorPicker.

PropTypeDefault
valueUseColorPickerReturnrequired
hideModeHideMode"display-none"
immediateboolean-
lazyMountbooleanfalse
onExitCompleteVoidFunction-
presentboolean-
skipAnimationOnMountbooleanfalse
unmountOnExitbooleanfalse
asChildbooleanfalse

ColorPickerArea

Interactive color area for selecting two color channels.

PropTypeDefault
xChannelColorChannel-
yChannelColorChannel-
asChildbooleanfalse

ColorPickerAreaBackground

Renders the gradient background for the color area.

PropTypeDefault
asChildbooleanfalse

ColorPickerAreaThumb

Renders the draggable thumb within the color area.

PropTypeDefault
asChildbooleanfalse

ColorPickerChannelSlider

A slider for selecting a color channel value.

PropTypeDefault
channelColorChannelrequired
orientationOrientation-
asChildbooleanfalse

ColorPickerChannelSliderControl

Wraps the channel slider track and thumb.

PropTypeDefault
asChildbooleanfalse

ColorPickerChannelSliderLabel

Labels a channel slider.

PropTypeDefault
asChildbooleanfalse

ColorPickerChannelSliderThumb

Renders the draggable thumb for a channel slider.

PropTypeDefault
asChildbooleanfalse

ColorPickerChannelSliderTrack

Renders the track for a channel slider.

PropTypeDefault
asChildbooleanfalse

ColorPickerChannelSliderValueText

Displays the current channel slider value.

PropTypeDefault
asChildbooleanfalse

ColorPickerChannelInput

An input for editing an individual color channel.

PropTypeDefault
channelExtendedColorChannelrequired
orientationOrientation-
asChildbooleanfalse

ColorPickerContent

Contains the picker interface displayed when the picker is open.

PropTypeDefault
asChildbooleanfalse

ColorPickerControl

Groups the trigger and color value controls.

PropTypeDefault
asChildbooleanfalse

ColorPickerEyeDropperTrigger

A button that opens the browser eye dropper, where supported.

PropTypeDefault
asChildbooleanfalse

ColorPickerFormatSelect

A native select for changing the color format.

PropTypeDefault
asChildbooleanfalse

ColorPickerFormatTrigger

A button that cycles through available color formats.

PropTypeDefault
asChildbooleanfalse

ColorPickerHiddenInput

A hidden form input containing the selected color value.

PropTypeDefault
asChildbooleanfalse

ColorPickerLabel

Labels the color picker.

PropTypeDefault
asChildbooleanfalse

ColorPickerPositioner

Positions the color picker content relative to its trigger.

PropTypeDefault
asChildbooleanfalse

ColorPickerSwatch

Displays a color swatch.

PropTypeDefault
valuestring | Colorrequired
respectAlphaboolean-
asChildbooleanfalse

ColorPickerSwatchGroup

Groups related color swatches.

PropTypeDefault
asChildbooleanfalse

ColorPickerSwatchIndicator

Indicates the selected swatch.

PropTypeDefault
asChildbooleanfalse

ColorPickerSwatchTrigger

A button that selects its associated swatch color.

PropTypeDefault
valuestring | Colorrequired
disabledboolean-
asChildbooleanfalse

ColorPickerTransparencyGrid

Renders a checkerboard background for transparent colors.

PropTypeDefault
sizestring-
asChildbooleanfalse

ColorPickerTrigger

A button that toggles the color picker.

PropTypeDefault
asChildbooleanfalse

ColorPickerValueSwatch

Displays a swatch for the current color value.

PropTypeDefault
respectAlphaboolean-
asChildbooleanfalse

ColorPickerValueText

Displays the current color value as text.

PropTypeDefault
formatColorStringFormat-
asChildbooleanfalse

ColorPickerView

Renders content for a specific color format.

PropTypeDefault
formatColorFormatrequired
asChildbooleanfalse