docs/components/color-picker
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Pick colors with hue and alpha controls.
PreviewCode
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/color-picker
You can use multiple modes to build the color picker that fits your needs:
ColorPicker
├── ColorPickerControl
│ └── InputGroup
│ ├── ColorPickerTrigger
│ │ └── ColorPickerSwatchPreview
│ └── ColorPickerInput
└── ColorPickerContent
├── ColorPickerArea
│ └── ColorPickerAreaThumb
└── ColorPickerView
└── ColorPickerSlider
import {
ColorPicker,
ColorPickerInput,
} from "@/components/ui/color-picker";
<ColorPicker>
<ColorPickerInput asChild channel="hex">
<Input />
</ColorPickerInput>
</ColorPicker>
Use the value and onValueChange props to programmatically control the color picker's state.
PreviewCode
#EB5E41
PreviewCode
Color
Please enter a valid hex color
PreviewCode
PreviewCode
Color
Enter your brand's primary color
PreviewCode
RGB
HSB
HSL
Hex
Input with ColorPickerSwatchPreview showing the current color alongside the hex input.
PreviewCode
An input with trigger and popover content for area, hue, and alpha selection.
PreviewCode
Inspired by Figma's color input.
PreviewCode
Color picker with trigger and popover content.
ColorPicker
├── ColorPickerControl
│ └── ColorPickerTrigger
└── ColorPickerContent
├── ColorPickerArea
│ └── ColorPickerAreaThumb
├── ColorPickerView
│ ├── ColorPickerEyeDropperTrigger
│ └── ColorPickerSlider
│ └── ColorPickerTransparencyGrid
└── ColorPickerSwatchGroup
└── ColorPickerSwatchTrigger
└── ColorPickerSwatch
import {
ColorPicker,
ColorPickerArea,
ColorPickerAreaThumb,
ColorPickerContent,
ColorPickerEyeDropperTrigger,
ColorPickerSlider,
ColorPickerTrigger,
ColorPickerTransparencyGrid,
ColorPickerView,
} from "@/components/ui/color-picker";
<ColorPicker>
<ColorPickerTrigger />
<ColorPickerContent>
<ColorPickerArea>
<ColorPickerAreaThumb />
</ColorPickerArea>
<ColorPickerView>
<ColorPickerEyeDropperTrigger />
<ColorPickerSlider channel="hue" />
<ColorPickerSlider channel="alpha">
<ColorPickerTransparencyGrid />
</ColorPickerSlider>
</ColorPickerView>
</ColorPickerContent>
</ColorPicker>
Set disabled to prevent user interaction.
PreviewCode
Pick as color
PreviewCode
Popover with area, sliders, and input fields for editing red, green, and blue values.
PreviewCode
Pick a color
Popover with hue, saturation, lightness, and alpha sliders only, no color area.
PreviewCode
Pick a color
Popover with preset color swatches for quick selection.
PreviewCode
Pick a color
Set inline on ColorPicker so swatches render without a popover.
ColorPicker
└── ColorPickerSwatchGroup
└── ColorPickerSwatchTrigger
└── ColorPickerSwatch
└── ColorPickerSwatchIndicator
import {
ColorPicker,
ColorPickerSwatchTrigger,
ColorPickerSwatchGroup,
ColorPickerSwatch,
ColorPickerSwatchIndicator,
} from "@/components/ui/color-picker";
<ColorPicker>
<ColorPickerSwatchGroup>
<ColorPickerSwatchTrigger value="#0485F7">
<ColorPickerSwatch value="#0485F7">
<ColorPickerSwatchIndicator />
</ColorPickerSwatch>
</ColorPickerSwatchTrigger>
</ColorPickerSwatchGroup>
</ColorPicker>
Use the value and onValueChange props to programmatically control the swatch picker's state.
PreviewCode
#0485F7
Set disabled to prevent user interaction.
PreviewCode
Customize swatch size using the size-* on ColorPickerSwatchTrigger.
PreviewCode
Override the default rounded style on ColorPickerSwatchTrigger using the rounded-* utility class.
PreviewCode
Replace the default check icon with a custom indicator via the children of ColorPickerSwatchIndicator.
PreviewCode
Set inline on ColorPicker for a standalone color area.
ColorPicker
└── ColorPickerArea
└── ColorPickerAreaThumb
import {
ColorPicker,
ColorPickerArea,
ColorPickerAreaThumb,
} from "@/components/ui/color-picker";
<ColorPicker>
<ColorPickerArea>
<ColorPickerAreaThumb />
</ColorPickerArea>
</ColorPicker>
PreviewCode
PreviewCode
Set inline on ColorPicker for standalone sliders. Wrap multiple sliders in ColorPickerView.
ColorPicker
└── ColorPickerView
└── ColorPickerSlider
└── ColorPickerTransparencyGrid
import {
ColorPicker,
ColorPickerSlider,
} from "@/components/ui/color-picker";
<ColorPicker>
<ColorPickerSlider channel="hue" />
</ColorPicker>
PreviewCode
rgba(82, 65, 235, 1)
PreviewCode
PreviewCode
PreviewCode
PreviewCode
PreviewCode
PreviewCode
Use [--space:--spacing("value")] on ColorPickerContent to adjust internal spacing.
Default spacing is --spacing(3).
PreviewCode
You can use breakpoint utilities to change the internal spacing at different screen sizes.
md:[--space:--spacing(6)] lg:[--space:--spacing(8)]
Root element of the color picker.
| Prop | Type | Default |
|---|---|---|
value | string | - |
defaultValue | string | - |
onValueChange | (details: ColorPickerValueChangeDetails) => void | - |
disabled | boolean | false |
format | `"hex" | "hexa" |
inline | boolean | false |
positioning | PositioningOptions | { placement: "top-start" } |
lazyMount | boolean | true |
unmountOnExit | boolean | true |
className | string | - |
Button or element that opens the color picker popover.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
Holds the color picker popover. Displayed in a portal.
| Prop | Type | Default |
|---|---|---|
className | string | - |
| Attribute | Default |
|---|---|
--space | --spacing(3) |
Container for grouping control elements such as area, sliders, and inputs.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Container for sliders and inputs. Can specify format for child value display.
| Prop | Type | Default |
|---|---|---|
format | `"hex" | "hexa" |
className | string | - |
Two-dimensional color selection area.
| Prop | Type | Default |
|---|---|---|
showDots | boolean | false |
xChannel | `"hue" | "saturation" |
yChannel | `"hue" | "saturation" |
className | string | - |
Draggable thumb within the color area.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Slider for adjusting a color channel.
| Prop | Type | Default |
|---|---|---|
channel | `"hex" | "hexa" |
orientation | `"horizontal" | "vertical"` |
className | string | - |
Checkerboard pattern for transparency. Shown as child of ColorPickerSlider when editing alpha.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Button that activates the native Eye Dropper API to sample colors from the screen.
| Prop | Type | Default |
|---|---|---|
variant | ButtonProps["variant"] | "outline" |
size | ButtonProps["size"] | "icon-md" |
children | ReactNode | Pipette |
className | string | - |
Input for displaying and editing a color channel value. Use asChild with a custom input.
| Prop | Type | Default |
|---|---|---|
channel | `"hex" | "hexa" |
asChild | boolean | false |
Compact swatch that displays the current color. Use inside an input group for input mode.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Container for swatch triggers in swatch picker mode.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Button that selects a color when clicked. Wraps ColorPickerSwatch and optionally ColorPickerSwatchIndicator.
| Prop | Type | Default |
|---|---|---|
value | string | - |
className | string | - |
Color swatch display. Use as a child of ColorPickerSwatchTrigger.
| Prop | Type | Default |
|---|---|---|
value | string | - |
className | string | - |
Check mark or custom icon shown when a swatch is selected. Pass children to customize.
| Prop | Type | Default |
|---|---|---|
children | ReactNode | CheckIcon |
className | string | - |
Displays the current color as formatted text.
| Prop | Type | Default |
|---|---|---|
format | `"hex" | "hexa" |
className | string | - |
Displays the current color as a swatch. Use for standalone value preview.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Exported utility to parse color strings. Use for programmatic color handling.
For the complete list of props and additional subcomponents, see the Ark UI Color Picker documentation.
[
Previous page
Collapsible ](/docs/components/collapsible)[
Next page
Combobox ](/docs/components/combobox)
On This Page
InstallationModesInputAnatomyUsageControlledStatesInvalidDisabledExamplesWith FieldChannel EditingWith SwatchWith PopoverCompactPopoverAnatomyUsageStatesDisabledExamplesWith Eye DropperWith Channel EditingWith Only SlidersWith Swatch PickerColor Swatch PickerAnatomyUsageControlledStatesDisabledExamplesCustom SizeCustom RadiusCustom IndicatorAreaAnatomyUsageExamplesColor ChannelsWith DotsSliderAnatomyUsageControlledStatesDisabledExamplesAlpha ChannelHSL ChannelsHSBA ChannelsRGB ChannelsVerticalCustom spacingAPI ReferenceColorPickerColorPickerTriggerColorPickerContentColorPickerControlColorPickerViewColorPickerAreaColorPickerAreaThumbColorPickerSliderColorPickerTransparencyGridColorPickerEyeDropperTriggerColorPickerInputColorPickerSwatchPreviewColorPickerSwatchGroupColorPickerSwatchTriggerColorPickerSwatchColorPickerSwatchIndicatorColorPickerValueColorPickerValueSwatchparseColor