shadcn.io is not affiliated with official shadcn/ui
Framework
UI library
Radix UI does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.
Installation
bunx --bun shadcn@latest add https://kit.dev/r/radix/color-picker.jsonUsage
import {
ColorPicker,
ColorPickerArea,
ColorPickerAreaThumb,
ColorPickerContent,
ColorPickerControl,
ColorPickerEyeDropperTrigger,
ColorPickerInput,
ColorPickerSlider,
ColorPickerSwatchPreview,
ColorPickerTransparencyGrid,
ColorPickerTrigger,
ColorPickerView,
} from "@/components/ui/color-picker";
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
} from "@/components/ui/input-group";<ColorPicker className="w-full max-w-64" defaultValue="#eb5e41" format="hsla">
<ColorPickerControl>
<InputGroup>
<ColorPickerTrigger asChild>
<InputGroupAddon>
<ColorPickerSwatchPreview />
</InputGroupAddon>
</ColorPickerTrigger>
<ColorPickerInput asChild>
<InputGroupInput />
</ColorPickerInput>
</InputGroup>
</ColorPickerControl>
<ColorPickerContent>
<ColorPickerArea>
<ColorPickerAreaThumb />
</ColorPickerArea>
<ColorPickerView format="hsla">
<div className="flex items-center gap-3">
<ColorPickerEyeDropperTrigger />
<div className="flex flex-1 flex-col gap-2.5">
<ColorPickerSlider channel="hue" />
<ColorPickerSlider channel="alpha">
<ColorPickerTransparencyGrid />
</ColorPickerSlider>
</div>
</div>
</ColorPickerView>
</ColorPickerContent>
</ColorPicker>Accessibility
| Key | Description |
|---|---|
Enter | Activate the focused control. |
Space | Activate the focused control. |
ArrowUp | Move up. |
ArrowDown | Move down. |
ArrowLeft | Move left. |
ArrowRight | Move right. |
PageUp | Jump backward. |
PageDown | Jump forward. |
Home | Go to the start. |
End | Go to the end. |
Escape | Dismiss. |
Demos
Area Channels
Area Dots
Context
Custom Spacing
Inline
Input Channel
Input Compact
Input Controlled
Input Disabled
Input Invalid
Input With Popover
Input With Swatch Preview
Open Controlled
Popover Disabled
Popover Sliders Only
Popover With Channel Editing
Popover With Swatch Picker
Root Provider
Slider Alpha Channel
Slider Controlled
Slider Disabled
Slider Hsba Channels
Slider Hsl Channels
Slider Rgb Channels
Slider Vertical
Swatch Picker
Swatch Picker Controlled
Swatch Picker Custom Indicator
Swatch Picker Custom Radius
Swatch Picker Custom Size
Swatch Picker Disabled
With Field
API Reference
ColorPicker
div
PropType
AttributeType
CSS variableType
--valuestringparseColor
PropType
AttributeType
ColorPickerLabel
label
PropType
AttributeType
ColorPickerControl
div
PropType
AttributeType
ColorPickerTrigger
button
PropType
AttributeType
ColorPickerTransparencyGrid
div
PropType
size?stringCSS variableType
--borderstringColorPickerContent
div
PropType
AttributeType
CSS variableType
--transform-originstringColorPickerView
div
PropType
formatColorFormatAttributeType
ColorPickerSlider
div
PropType
channelColorChannelAttributeType
ColorPickerEyeDropperTrigger
button
PropType
AttributeType
ColorPickerSwatchGroup
div
PropType
AttributeType
ColorPickerSwatchTrigger
button
PropType
AttributeType
CSS variableType
--colorstringColorPickerSwatch
div
PropType
AttributeType
CSS variableType
--colorstringColorPickerSwatchIndicator
div
PropType
AttributeType
ColorPickerValue
span
PropType
format?ColorStringFormatAttributeType
ColorPickerValueSwatch
div
PropType
AttributeType
ColorPickerArea
div
PropType
xChannel?ColorChannelyChannel?ColorChannelAttributeType
CSS variableType
--borderstringColorPickerAreaThumb
div
PropType
AttributeType
ColorPickerInput
input
PropType
AttributeType
ColorPickerSwatchPreview
div
PropType
size?stringCSS variableType
--borderstringColorPickerRootProvider
div
PropType
valueUseColorPickerReturnAttributeType
CSS variableType
--valuestringuseColorPicker
PropType
ColorPickerContext
PropType