Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Color Picker for React and Tailwind

Pick colors with hue and alpha controls.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/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

parseColor

AttributeType

ColorPickerLabel

label

PropType
AttributeType

ColorPickerControl

div

PropType
AttributeType

ColorPickerTrigger

button

PropType
AttributeType

ColorPickerTransparencyGrid

div

PropType
CSS variableType

ColorPickerContent

div

PropType
AttributeType
CSS variableType

ColorPickerView

div

PropType
AttributeType

ColorPickerSlider

div

PropType
AttributeType

ColorPickerEyeDropperTrigger

button

PropType
AttributeType

ColorPickerSwatchGroup

div

PropType
AttributeType

ColorPickerSwatchTrigger

button

PropType
AttributeType
CSS variableType

ColorPickerSwatch

div

PropType
AttributeType
CSS variableType

ColorPickerSwatchIndicator

div

PropType
AttributeType

ColorPickerValue

span

PropType
AttributeType

ColorPickerValueSwatch

div

PropType
AttributeType

ColorPickerArea

div

PropType
AttributeType

ColorPickerAreaThumb

div

PropType
AttributeType

ColorPickerInput

input

PropType
AttributeType

ColorPickerSwatchPreview

div

PropType
CSS variableType

ColorPickerRootProvider

div

PropType
AttributeType
CSS variableType

useColorPicker

PropType

ColorPickerContext

PropType