UIComponentsReact
A color area, channel sliders, a wheel and text inputs that edit one color, inline or in a popup.
Built on the headless Color Picker.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/color-picker.jsonIt also adds utils, button. The app needs its setup first: Installation.
Usage
Write the surfaces you want inside ColorPicker: ColorPickerArea and ColorPickerChannelSlider each with their thumb, ColorPickerWheel with ColorPickerWheelThumb, ColorPickerInput for the text, ColorPickerChannelInput for one channel, ColorPickerSwatch, ColorPickerValue and ColorPickerEyeDropper. Add a ColorPickerTrigger and put the surfaces in ColorPickerPortal > ColorPickerPositioner > ColorPickerPopup to open them in a popup; ColorPickerClose closes it. The gradients, the keys, the names read out for a color, the formats and the form value come from the headless Color Picker.
import {
ColorPicker,
ColorPickerArea,
ColorPickerAreaThumb,
ColorPickerChannelInput,
ColorPickerChannelSlider,
ColorPickerChannelSliderThumb,
ColorPickerClose,
ColorPickerEyeDropper,
ColorPickerInput,
ColorPickerPopup,
ColorPickerPortal,
ColorPickerPositioner,
ColorPickerSwatch,
ColorPickerTrigger,
ColorPickerValue,
ColorPickerWheel,
ColorPickerWheelThumb,
} from '@/components/ui/color-picker'Examples
Default
An area, hue and alpha sliders, a swatch and the hex input inline.
shadcn/ui has no Color Picker, so this item takes Base UI's component ID as its slug and one name per Base UI part. Every thumb is a white ring with a dark outline inside and out, so it reads on any color; the alpha slider and the swatches sit on a checkerboard so a transparent color shows. The popup is Popover's, and Trigger, Close and EyeDropper take Button's variants. Color Swatch and Color Swatch Picker work alone and inside the picker.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Color Picker's API reference.