Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Color Picker for React Radix UI

Pick colors with hue and alpha controls.

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.json

Usage

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

KeyDescription
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
--valuestring

parseColor

PropType
AttributeType

ColorPickerLabel

label

PropType
AttributeType

ColorPickerControl

div

PropType
AttributeType

ColorPickerTrigger

button

PropType
AttributeType

ColorPickerTransparencyGrid

div

PropType
size?string
CSS variableType
--borderstring

ColorPickerContent

div

PropType
AttributeType
CSS variableType
--transform-originstring

ColorPickerView

div

PropType
formatColorFormat
AttributeType

ColorPickerSlider

div

PropType
channelColorChannel
AttributeType

ColorPickerEyeDropperTrigger

button

PropType
AttributeType

ColorPickerSwatchGroup

div

PropType
AttributeType

ColorPickerSwatchTrigger

button

PropType
AttributeType
CSS variableType
--colorstring

ColorPickerSwatch

div

PropType
AttributeType
CSS variableType
--colorstring

ColorPickerSwatchIndicator

div

PropType
AttributeType

ColorPickerValue

span

PropType
format?ColorStringFormat
AttributeType

ColorPickerValueSwatch

div

PropType
AttributeType

ColorPickerArea

div

PropType
xChannel?ColorChannel
yChannel?ColorChannel
AttributeType
CSS variableType
--borderstring

ColorPickerAreaThumb

div

PropType
AttributeType

ColorPickerInput

input

PropType
AttributeType

ColorPickerSwatchPreview

div

PropType
size?string
CSS variableType
--borderstring

ColorPickerRootProvider

div

PropType
valueUseColorPickerReturn
AttributeType
CSS variableType
--valuestring

useColorPicker

PropType

ColorPickerContext

PropType