DocumentationComposable Components

Composable Components

Need a different layout? Skip ColorPicker and assemble the primitives yourself. They share one state object fromuseColorState, so each control needs only two props.

Build your own picker

The color area, sliders, inputs, and preview below are separate exports, composed around one useColorState call.

Composed from primitives
hex#6366f1
rgbrgb(99, 102, 241)
rgbargba(99, 102, 241, 1.00)
hslhsl(238.7, 83.5%, 66.7%)
hslahsla(238.7, 83.5%, 66.7%, 1.00)
oklchoklch(58.5% 0.204 277.1)
oklchaoklch(58.5% 0.204 277.1 / 1.00)

Canvas & sliders

The draggable surfaces. All three share one prop interface and read from the same useColorState.

ColorArea

Two-dimensional saturation and brightness area.

PropTypeDescription
hsva* requiredHSVACurrent color as HSVA (from useColorState).
onChange* required(hsva: HSVA) => voidCalled as the user drags.
onStart() => voidFires on drag start.
onEnd() => voidFires on drag end.
widthnumberWidth in pixels.
heightnumberHeight in pixels.
classNamestringExtra classes.

HueSlider

Hue selection track.

PropTypeDescription
hsva* requiredHSVACurrent color as HSVA (from useColorState).
onChange* required(hsva: HSVA) => voidCalled as the user drags.
onStart() => voidFires on drag start.
onEnd() => voidFires on drag end.
verticalbooleanRender vertically.
classNamestringExtra classes.

AlphaSlider

Transparency track with checkerboard.

PropTypeDescription
hsva* requiredHSVACurrent color as HSVA (from useColorState).
onChange* required(hsva: HSVA) => voidCalled as the user drags.
onStart() => voidFires on drag start.
onEnd() => voidFires on drag end.
verticalbooleanRender vertically.
classNamestringExtra classes.

Display

Previews, swatches, and single-purpose buttons.

ColorPreview

Swatch, optionally comparing against an original color.

PropTypeDescription
colorValue* requiredColorValueColor to preview.
showComparisonbooleanSplit the swatch to show before / after.
originalColorstringThe "before" color for comparison.
size'sm' | 'md' | 'lg'Swatch size.
classNamestringExtra classes.

ColorSwatch

A single selectable color button.

PropTypeDescription
color* requiredstringThe color it represents.
selectedbooleanShow the active ring.
onClick() => voidClick handler.
onLongPress() => voidLong-press handler (edit).
onDelete() => voidDelete handler.
editingbooleanRender in editing state.
classNamestringExtra classes.

CopyButton

Copies text to the clipboard with feedback.

PropTypeDescription
text* requiredstringThe text to copy.
labelstringAccessible label / tooltip.
onCopy(success: boolean) => voidCalled after a copy attempt.
classNamestringExtra classes.

EyeDropperButton

Screen color sampler backed by the EyeDropper API. Renders nothing where the API is unavailable.

PropTypeDescription
onPick* required(color: string) => voidReceives the picked hex color.
labelstringAccessible label / tooltip.
classNamestringExtra classes.

Inputs

Text and numeric fields. ColorInputs switches between formats; the per-format variants render a fixed set of channels.

ColorInputs

Format-switchable input group.

PropTypeDescription
colorValue* requiredColorValueCurrent color (all formats).
onChange* required(colorString: string) => voidReceives the edited color as a string.
format* requiredColorFormatActive format.
onFormatChange(format: ColorFormat) => voidCalled when the user switches format.
showCopyButtonbooleanShow the copy-to-clipboard button.
onCopy(success: boolean) => voidCalled after a copy attempt.
showAlphabooleanInclude the alpha channel field.
availableFormatsColorFormat[]Formats offered in the switcher.
classNamestringExtra classes.

RGBInputs · HSLInputs · HSVInputs · OKLCHInputs · OKLABInputs

Fixed per-space channel fields. Identical prop shape across all five.

PropTypeDescription
colorValue* requiredColorValueCurrent color (all formats).
onChange* required(colorString: string) => voidReceives the edited color as a string.
showAlphabooleanInclude the alpha channel field.
classNamestringExtra classes.

Collections

Swatch grids for presets and history.

PresetColors

Editable preset grid with optional named groups.

PropTypeDescription
colors* requiredstring[]Swatches to display.
onSelect* required(color: string) => voidCalled when a swatch is chosen.
selectedColorstringHighlights the matching swatch.
editablebooleanAllow add / edit / delete.
presetGroupsPresetGroup[]Named groups for the dropdown.
classNamestringExtra classes.

RecentColors

Recently used colors. Reads localStorage on mount, or renders the colors prop when supplied.

PropTypeDescription
onColorSelect* required(color: string) => voidCalled when a recent color is chosen.
colorsstring[]Controlled list; overrides localStorage.
classNamestringExtra classes.