ChromaKit logo

ChromaKit

DemoDocsGitHub

Composable Components

Prefer full control over layout? Drop the wrapper and assemble the primitives yourself. They all share one state object fromuseColorState, so wiring them together is trivial.

Build your own picker

The color area, sliders, inputs, and preview below are all separate exports composed by hand around a single useColorState hook.

Build Your Own Picker
Compose individual components to create a custom color picker
hex#6366f1
rgbrgb(99, 102, 241)
rgbargba(99, 102, 241, 1.00)
hslhsl(239, 84%, 67%)
hslahsla(239, 84%, 67%, 1.00)
oklchoklch(59% 0.20 277)
oklchaoklch(59% 0.20 277 / 1.00)

Canvas & sliders

The draggable surfaces. All three take the same drag interface, so they compose cleanly around a single useColorState.

ColorArea

2D saturation / value square.

PropTypeDescription
hsva*HSVACurrent color as HSVA (from useColorState).
onChange*(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*HSVACurrent color as HSVA (from useColorState).
onChange*(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*HSVACurrent color as HSVA (from useColorState).
onChange*(hsva: HSVA) => voidCalled as the user drags.
onStart() => voidFires on drag start.
onEnd() => voidFires on drag end.
verticalbooleanRender vertically.
classNamestringExtra classes.

Inputs

Text / numeric fields. ColorInputs switches formats itself; the per-space variants render a fixed set of channels.

ColorInputs

Format-switchable input group.

PropTypeDescription
colorValue*ColorValueCurrent color (all formats).
onChange*(colorString: string) => voidReceives the edited color as a string.
format*ColorFormatActive format.
onFormatChange(format: ColorFormat) => voidCalled when the user switches format.
showAlphabooleanInclude the alpha channel field.
availableFormatsColorFormat[]Formats offered in the switcher.
classNamestringExtra classes.

RGBInputs · HSLInputs · HSVInputs · OKLCHInputs

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

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

Display

Read-only and action pieces.

ColorPreview

Swatch, optionally comparing against an original color.

PropTypeDescription
colorValue*ColorValueColor 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*stringThe 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*stringThe text to copy.
labelstringAccessible label / tooltip.
onCopy(success: boolean) => voidCalled after a copy attempt.
classNamestringExtra classes.

Collections

Swatch grids for presets and history.

PresetColors

Editable preset grid with optional named groups.

PropTypeDescription
colors*string[]Swatches to display.
onSelect*(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*(color: string) => voidCalled when a recent color is chosen.
colorsstring[]Controlled list; overrides localStorage.
classNamestringExtra classes.