# Shadcn Color Picker

A color picker built from parts you arrange yourself: a two channel area, hue and alpha sliders, a text input that reads any CSS color, number inputs per channel, preset swatches and an eye dropper. It edits in HSV, HSL, sRGB or OKLCH, writes the value as hex or any CSS color syntax, and keeps colors inside the sRGB or P3 gamut. Every part works with the keyboard and screen readers.

`color-picker-demo.tsx`:

```tsx
import {
  ColorPicker,
  ColorPickerArea,
  ColorPickerEyeDropper,
  ColorPickerInput,
  ColorPickerSlider,
  ColorPickerSwatch,
} from "@/components/ui/color-picker";

export default function ColorPickerDemo() {
  return (
    <ColorPicker aria-label="Color" defaultValue="#6366f1">
      <ColorPickerArea />
      <ColorPickerSlider channel="hue" />
      <div className="flex items-center gap-2">
        <ColorPickerSwatch />
        <ColorPickerInput aria-label="Hex" />
        <ColorPickerEyeDropper aria-label="Pick from screen" />
      </div>
    </ColorPicker>
  );
}
```

## Installation

```bash
npx shadcn@latest add @shadcnuikit/color-picker1
```

This adds `components/ui/color-picker.tsx`, the `button` and `input` components it depends on, and a demo file. Set up the registry once as described in [Shadcn CLI](https://shadcnuikit.com/docs/shadcn-cli). Color Picker is free and installs without an API key.

### Manual installation

Install the dependencies and the shadcn/ui components:

```bash
npm install @ui-sdk/react@beta lucide-react
npx shadcn@latest add button input
```

Copy the source into `components/ui/color-picker.tsx`:

`components/ui/color-picker.tsx`:

```tsx
"use client";

import * as React from "react";
import {
  ColorPicker as ColorPickerPrimitive,
  ColorPickerArea as ColorPickerAreaPrimitive,
  ColorPickerAreaCanvas as ColorPickerAreaCanvasPrimitive,
  ColorPickerAreaThumb as ColorPickerAreaThumbPrimitive,
  ColorPickerChannelInput as ColorPickerChannelInputPrimitive,
  ColorPickerEyeDropper as ColorPickerEyeDropperPrimitive,
  ColorPickerInput as ColorPickerInputPrimitive,
  ColorPickerSlider as ColorPickerSliderPrimitive,
  ColorPickerSliderThumb as ColorPickerSliderThumbPrimitive,
  ColorPickerSwatch as ColorPickerSwatchPrimitive,
  ColorPickerSwatches as ColorPickerSwatchesPrimitive,
  ColorPickerSwatchItem as ColorPickerSwatchItemPrimitive,
  createColorPickerController,
} from "@ui-sdk/react/color-picker";
import { PipetteIcon } from "lucide-react";

import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";

const checkerboard =
  "bg-[repeating-conic-gradient(var(--muted)_0_25%,var(--background)_0_50%)] bg-size-[8px_8px]";

const thumb =
  "size-4 -translate-1/2 rtl:translate-x-1/2 rounded-full border-2 border-white bg-(--color-picker-color) shadow-sm ring-1 ring-black/10 outline-none transition-[box-shadow] focus-visible:ring-[3px] focus-visible:ring-ring/50";

type WithClassName<T> = Omit<T, "className"> & { className?: string };

function ColorPicker({
  className,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerPrimitive>>) {
  return (
    <ColorPickerPrimitive
      className={cn(
        "flex w-64 flex-col gap-3 data-disabled:pointer-events-none data-disabled:opacity-50",
        className,
      )}
      {...props}
    />
  );
}

function ColorPickerArea({
  className,
  children,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerAreaPrimitive>>) {
  return (
    <ColorPickerAreaPrimitive
      className={cn(
        "relative h-40 w-full touch-none rounded-md border bg-(image:--color-area-background) has-[[data-slot=color-picker-area-canvas]]:bg-muted",
        className,
      )}
      {...props}
    >
      {children ?? <ColorPickerAreaThumb />}
    </ColorPickerAreaPrimitive>
  );
}

function ColorPickerAreaCanvas({
  className,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerAreaCanvasPrimitive>>) {
  return (
    <ColorPickerAreaCanvasPrimitive
      className={cn("absolute inset-0 size-full rounded-[inherit]", className)}
      {...props}
    />
  );
}

function ColorPickerAreaThumb({
  className,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerAreaThumbPrimitive>>) {
  return (
    <ColorPickerAreaThumbPrimitive
      className={cn(thumb, "cursor-grab active:cursor-grabbing", className)}
      {...props}
    />
  );
}

function ColorPickerSlider({
  className,
  children,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerSliderPrimitive>>) {
  return (
    <ColorPickerSliderPrimitive
      className={cn(
        "relative h-3 w-full shrink-0 touch-none rounded-full",
        "data-[orientation=vertical]:h-auto data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-3",
        "data-[channel=alpha]:[background:var(--color-slider-background),repeating-conic-gradient(var(--muted)_0_25%,var(--background)_0_50%)_0_0/8px_8px]",
        "not-data-[channel=alpha]:[background:var(--color-slider-background)]",
        className,
      )}
      {...props}
    >
      {children ?? <ColorPickerSliderThumb />}
    </ColorPickerSliderPrimitive>
  );
}

function ColorPickerSliderThumb({
  className,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerSliderThumbPrimitive>>) {
  return (
    <ColorPickerSliderThumbPrimitive
      className={cn(
        thumb,
        // Vertical thumbs are placed with `bottom`, so they shift down by half instead of up.
        "data-[orientation=horizontal]:top-1/2 data-[orientation=vertical]:inset-s-1/2 data-[orientation=vertical]:translate-y-1/2",
        className,
      )}
      {...props}
    />
  );
}

function ColorPickerSwatch({
  className,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerSwatchPrimitive>>) {
  return (
    <ColorPickerSwatchPrimitive
      className={cn(
        "relative size-9 shrink-0 overflow-hidden rounded-md border",
        checkerboard,
        "after:absolute after:inset-0 after:bg-(--color-picker-color) after:content-['']",
        className,
      )}
      {...props}
    />
  );
}

function ColorPickerInput({
  className,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerInputPrimitive>>) {
  return (
    <ColorPickerInputPrimitive
      render={<Input />}
      className={cn("font-mono text-sm", className)}
      {...props}
    />
  );
}

function ColorPickerChannelInput({
  className,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerChannelInputPrimitive>>) {
  return (
    <ColorPickerChannelInputPrimitive
      render={<Input />}
      className={cn("min-w-0 px-2 text-center font-mono text-sm tabular-nums", className)}
      {...props}
    />
  );
}

function ColorPickerEyeDropper({
  className,
  children,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerEyeDropperPrimitive>>) {
  return (
    <ColorPickerEyeDropperPrimitive
      render={<Button variant="outline" size="icon" />}
      className={cn("shrink-0 data-unsupported:hidden", className)}
      {...props}
    >
      {children ?? <PipetteIcon aria-hidden="true" />}
    </ColorPickerEyeDropperPrimitive>
  );
}

function ColorPickerSwatches({
  className,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerSwatchesPrimitive>>) {
  return (
    <ColorPickerSwatchesPrimitive
      className={cn("flex flex-wrap gap-2", className)}
      {...props}
    />
  );
}

function ColorPickerSwatchItem({
  className,
  ...props
}: WithClassName<React.ComponentProps<typeof ColorPickerSwatchItemPrimitive>>) {
  return (
    <ColorPickerSwatchItemPrimitive
      className={cn(
        "relative size-7 cursor-pointer overflow-hidden rounded-md border outline-none transition-[box-shadow,scale]",
        checkerboard,
        "after:absolute after:inset-0 after:bg-(--color-picker-color) after:content-['']",
        "hover:scale-110 focus-visible:ring-[3px] focus-visible:ring-ring/50",
        "aria-selected:ring-2 aria-selected:ring-ring aria-selected:ring-offset-2 aria-selected:ring-offset-background",
        className,
      )}
      {...props}
    />
  );
}

export {
  ColorPicker,
  ColorPickerArea,
  ColorPickerAreaCanvas,
  ColorPickerAreaThumb,
  ColorPickerChannelInput,
  ColorPickerEyeDropper,
  ColorPickerInput,
  ColorPickerSlider,
  ColorPickerSliderThumb,
  ColorPickerSwatch,
  ColorPickerSwatches,
  ColorPickerSwatchItem,
  createColorPickerController,
};
```

## Usage

```tsx
import {
  ColorPicker,
  ColorPickerArea,
  ColorPickerInput,
  ColorPickerSlider,
  ColorPickerSwatch,
} from "@/components/ui/color-picker";
```

```tsx
<ColorPicker aria-label="Brand color" defaultValue="#6366f1">
  <ColorPickerArea />
  <ColorPickerSlider channel="hue" />
  <ColorPickerSwatch />
  <ColorPickerInput aria-label="Hex" />
</ColorPicker>
```

Give the picker a name with `aria-label`. The value is always a CSS color string. Without `format`, the default HSV space writes it as hex, like `"#6366f1"`, or `"#6366f1cc"` with alpha.

### Controlled

```tsx
const [color, setColor] = React.useState("#6366f1");

<ColorPicker aria-label="Brand color" value={color} onValueChange={setColor}>
  <ColorPickerArea />
  <ColorPickerSlider channel="hue" />
</ColorPicker>;
```

`onValueChange` runs on every step of a drag. Use `onValueCommit` to save once the pointer lifts or a key is pressed.

### In a popover

```tsx
<Popover>
  <PopoverTrigger asChild>
    <Button variant="outline">Pick a color</Button>
  </PopoverTrigger>
  <PopoverContent className="w-auto">
    <ColorPicker aria-label="Color" value={color} onValueChange={setColor}>
      <ColorPickerArea />
      <ColorPickerSlider channel="hue" />
    </ColorPicker>
  </PopoverContent>
</Popover>
```

## Examples

### Alpha

Add a `ColorPickerSlider` with `channel="alpha"`. The checkerboard behind it shows the transparency.

`color-picker-alpha.tsx`:

```tsx
import {
  ColorPicker,
  ColorPickerArea,
  ColorPickerInput,
  ColorPickerSlider,
  ColorPickerSwatch,
} from "@/components/ui/color-picker";

export default function ColorPickerAlpha() {
  return (
    <ColorPicker aria-label="Overlay color" defaultValue="#0ea5e999">
      <ColorPickerArea />
      <ColorPickerSlider channel="hue" />
      <ColorPickerSlider channel="alpha" />
      <div className="flex items-center gap-2">
        <ColorPickerSwatch />
        <ColorPickerInput aria-label="Hex" />
      </div>
    </ColorPicker>
  );
}
```

### Format

`format` sets how the value is written: `hex`, `srgb`, `hsl`, `hwb`, `lab`, `lch`, `oklab` or `oklch`. The input shows the same syntax. The starting value is kept as you pass it until the first change, so write `defaultValue` in the same format.

`color-picker-format.tsx`:

```tsx
import { ColorPicker, ColorPickerInput, ColorPickerSlider, ColorPickerSwatch } from "@/components/ui/color-picker";

const formats = [
  { format: "hex", value: "#16a34a" },
  { format: "srgb", value: "rgb(22 163 74)" },
  { format: "hsl", value: "hsl(142 76% 36%)" },
  { format: "oklch", value: "oklch(0.63 0.17 149)" },
] as const;

export default function ColorPickerFormat() {
  return (
    <div className="flex flex-col gap-4">
      {formats.map(({ format, value }) => (
        <ColorPicker key={format} aria-label={`Color as ${format}`} format={format} defaultValue={value}>
          <ColorPickerSlider channel="hue" />
          <div className="flex items-center gap-2">
            <ColorPickerSwatch />
            <ColorPickerInput aria-label={`${format} value`} />
          </div>
        </ColorPicker>
      ))}
    </div>
  );
}
```

### OKLCH

`space="oklch"` edits lightness, chroma and hue. Put a `ColorPickerAreaCanvas` in the area, since no CSS gradient can draw chroma by lightness.

`color-picker-oklch.tsx`:

```tsx
import {
  ColorPicker,
  ColorPickerArea,
  ColorPickerAreaCanvas,
  ColorPickerAreaThumb,
  ColorPickerInput,
  ColorPickerSlider,
  ColorPickerSwatch,
} from "@/components/ui/color-picker";

export default function ColorPickerOklch() {
  return (
    <ColorPicker aria-label="Accent" space="oklch" defaultValue="oklch(0.62 0.19 259)">
      <ColorPickerArea>
        <ColorPickerAreaCanvas />
        <ColorPickerAreaThumb />
      </ColorPickerArea>
      <ColorPickerSlider channel="hue" />
      <div className="flex items-center gap-2">
        <ColorPickerSwatch />
        <ColorPickerInput aria-label="OKLCH" />
      </div>
    </ColorPicker>
  );
}
```

### Channel Inputs

`ColorPickerChannelInput` edits one `channel` as a number, like red from 0 to 255. With `space="srgb"`, sliders and inputs can edit red, green and blue.

`color-picker-channel-inputs.tsx`:

```tsx
import {
  ColorPicker,
  ColorPickerChannelInput,
  ColorPickerSlider,
  ColorPickerSwatch,
} from "@/components/ui/color-picker";

const channels = ["red", "green", "blue"] as const;

export default function ColorPickerChannelInputs() {
  return (
    <ColorPicker aria-label="Color" space="srgb" format="hex" defaultValue="#f97316">
      {channels.map((channel) => (
        <div key={channel} className="flex items-center gap-3">
          <ColorPickerSlider channel={channel} />
          <ColorPickerChannelInput channel={channel} className="w-16 shrink-0" />
        </div>
      ))}
      <ColorPickerSwatch className="h-9 w-full" />
    </ColorPicker>
  );
}
```

### Swatches

`ColorPickerSwatches` holds preset `ColorPickerSwatchItem`s. Pressing one sets the value, and the one that matches the current color is selected.

`color-picker-swatches.tsx`:

```tsx
import {
  ColorPicker,
  ColorPickerInput,
  ColorPickerSwatch,
  ColorPickerSwatches,
  ColorPickerSwatchItem,
} from "@/components/ui/color-picker";

const presets = ["#ef4444", "#f97316", "#eab308", "#22c55e", "#06b6d4", "#3b82f6", "#8b5cf6", "#ec4899"];

export default function ColorPickerSwatchesDemo() {
  return (
    <ColorPicker aria-label="Label color" defaultValue="#3b82f6">
      <ColorPickerSwatches aria-label="Presets">
        {presets.map((preset) => (
          <ColorPickerSwatchItem key={preset} value={preset} />
        ))}
      </ColorPickerSwatches>
      <div className="flex items-center gap-2">
        <ColorPickerSwatch />
        <ColorPickerInput aria-label="Hex" />
      </div>
    </ColorPicker>
  );
}
```

### Vertical

`orientation="vertical"` turns a slider upright. Vertical sliders grow upward.

`color-picker-vertical.tsx`:

```tsx
import { ColorPicker, ColorPickerArea, ColorPickerSlider } from "@/components/ui/color-picker";

export default function ColorPickerVertical() {
  return (
    <ColorPicker aria-label="Color" defaultValue="#8b5cf6cc" className="w-72 flex-row">
      <ColorPickerArea className="flex-1" />
      <ColorPickerSlider channel="hue" orientation="vertical" />
      <ColorPickerSlider channel="alpha" orientation="vertical" />
    </ColorPicker>
  );
}
```

### Disabled

`color-picker-disabled.tsx`:

```tsx
import {
  ColorPicker,
  ColorPickerArea,
  ColorPickerInput,
  ColorPickerSlider,
  ColorPickerSwatch,
} from "@/components/ui/color-picker";

export default function ColorPickerDisabled() {
  return (
    <ColorPicker aria-label="Color" defaultValue="#6366f1" disabled>
      <ColorPickerArea />
      <ColorPickerSlider channel="hue" />
      <div className="flex items-center gap-2">
        <ColorPickerSwatch />
        <ColorPickerInput aria-label="Hex" />
      </div>
    </ColorPicker>
  );
}
```

More layouts built with Color Picker, such as a popover picker and presets with RGB inputs, are on the [Color Picker components](https://shadcnuikit.com/components/color-picker) page.

## API Reference

### ColorPicker

The root. A group around the parts, plus the hidden input the form submits.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` | | The color, as any CSS color, like `"#0ea5e9"` or `"oklch(0.62 0.19 259)"`. Pass it to control the picker. |
| `defaultValue` | `string` | black | The color at first, when uncontrolled. A form reset returns to it. |
| `onValueChange` | `(value, details) => void` | | Runs on every step of a drag or key. `details.color` is the color object, `details.cancel()` stops the change. |
| `onValueCommit` | `(value, details) => void` | | Runs once an interaction ends: the pointer lifts, a key is pressed, a swatch is picked. Use it for saving. |
| `space` | `"hsv"`, `"hsl"`, `"srgb"`, `"oklch"` | `"hsv"` | The space the parts edit in, which decides their channels. |
| `format` | `"hex"`, `"srgb"`, `"hsl"`, `"hwb"`, `"lab"`, `"lch"`, `"oklab"`, `"oklch"` | `"hex"` for HSV, the space otherwise | How the value is written. |
| `gamut` | `"srgb"`, `"p3"`, `false` | `"srgb"` | The colors the value can hold. Colors outside it move to the closest one inside. `false` allows any color. |
| `disabled` | `boolean` | `false` | Disables every part. The value is not submitted. |
| `readOnly` | `boolean` | `false` | Keeps the parts focusable and the value submitted, but stops changes. |
| `required` | `boolean` | `false` | Adds `data-required`. A picker always has a value, so it never blocks a form. |
| `name` | `string` | | The name the value submits under. Without one, nothing is submitted. |
| `form` | `string` | | The id of a form to belong to, when the picker is outside it. |
| `controller` | `ColorPickerController` | | Sets the value from anywhere. Create one with `createColorPickerController()`. |
| `className` | `string` | | Classes for the root. |

The root has `data-disabled`, `data-readonly`, `data-required` and `data-out-of-gamut` attributes for styling.

### ColorPickerArea

A surface for two channels. Renders a `ColorPickerAreaThumb` when it has no children.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `x` | `ColorChannel` | saturation, red or chroma, by space | The channel from left to right. |
| `y` | `ColorChannel` | brightness, lightness or green, by space | The channel from bottom to top. |
| `className` | `string` | | Classes for the area. |

`ColorChannel` is one of `"hue"`, `"saturation"`, `"brightness"`, `"lightness"`, `"chroma"`, `"red"`, `"green"`, `"blue"` or `"alpha"`.

A CSS gradient draws the area only in HSV and HSL with saturation across and brightness or lightness up. For any other space or axes, add a `ColorPickerAreaCanvas`.

### ColorPickerAreaThumb

The area's draggable thumb. Use it as a child of `ColorPickerArea` when you add a canvas.

### ColorPickerAreaCanvas

Paints the area pixel by pixel, for channels no gradient can draw, like OKLCH chroma by lightness. Colors outside the gamut stay transparent.

### ColorPickerSlider

A track for one channel. Renders a `ColorPickerSliderThumb` when it has no children.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `channel` | `ColorChannel` | hue, or blue in sRGB | The channel the slider edits. |
| `orientation` | `"horizontal"`, `"vertical"` | `"horizontal"` | The slider's axis. Vertical sliders grow upward. |
| `className` | `string` | | Classes for the track. |

The track has `data-channel` and `data-orientation`. The alpha track gets a checkerboard background.

### ColorPickerSliderThumb

The slider's thumb, placed at `--color-slider-thumb-position`.

### ColorPickerInput

A text input that reads any CSS color on `Enter` or blur. Text that isn't a color goes back to the value. It takes every `Input` prop.

### ColorPickerChannelInput

A number input for one channel, in the units people read it in: degrees for hue, percentages, 0 to 255 for red, green and blue.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `channel` | `ColorChannel` | hue, or blue in sRGB | The channel the input edits. |
| `className` | `string` | | Classes for the input. |

### ColorPickerSwatch

Shows the current color over a checkerboard, as `--color-picker-color`.

### ColorPickerEyeDropper

A button that picks a color from the screen with the browser's EyeDropper API. Where the browser has no support, it gets `data-unsupported` and is hidden. Give it an `aria-label`. Its default icon is `PipetteIcon`.

### ColorPickerSwatches

A list of preset colors. Give it an `aria-label`.

### ColorPickerSwatchItem

One preset.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `string` | | The color it picks, as any CSS color. |
| `className` | `string` | | Classes for the swatch. |

The item has `aria-selected` and `data-selected` when its color matches the picker's.

### createColorPickerController

```tsx
const [controller] = React.useState(() => createColorPickerController());

<ColorPicker aria-label="Color" controller={controller} />;

controller.setValue("#22c55e");
controller.getValue();
controller.focus();
```

## Keyboard

### Area and sliders

| Key | Action |
| --- | --- |
| `ArrowLeft`, `ArrowRight` | Moves the area thumb along `x`, or steps a horizontal slider. |
| `ArrowUp`, `ArrowDown` | Moves the area thumb along `y`, or steps a slider. |
| `Shift` + arrow | Moves ten steps. |
| `PageUp`, `PageDown` | Moves a tenth of the range: `y` on the area, the channel on a slider. |
| `Home`, `End` | Goes to the lowest or highest value: `x` on the area, the channel on a slider. |

### Inputs and swatches

| Key | Action |
| --- | --- |
| `Enter` | Reads the typed color in `ColorPickerInput`. |
| `Escape` | Reverts typed text in `ColorPickerInput` to the value. |
| `ArrowLeft`, `ArrowRight`, `ArrowUp`, `ArrowDown` | Moves between swatches. |
| `Home`, `End` | Moves to the first or last swatch. |
| `Enter`, `Space` | Picks the focused swatch. |

## Accessibility

- The area thumb is a `slider` named for both channels, such as "Saturation and brightness". Each slider thumb is a `slider` named for its channel, with its value in readable units.
- The swatch is an `img` named with a description of the color. Swatches are a `listbox` of `option`s named the same way.
- Labels are English by default. Pass `aria-label` to any part to translate it.
- Always name the picker with `aria-label`, and name `ColorPickerInput` and `ColorPickerEyeDropper` too.

## For AI Agents

**When to use**

- Choosing any color: brand colors, theme editors, label and tag colors, drawing and design tools.
- Picking wide gamut or perceptual colors, with `space="oklch"` and `gamut="p3"`.
- A short preset palette with the option to pick something custom, with `ColorPickerSwatches`.

**When not to use**

- Choosing between a few fixed colors only. Render `ColorPickerSwatches` alone, or use a [Radio Group](https://shadcnuikit.com/components/radio-group).
- Picking a theme token like primary or muted. Use a [Select](https://shadcnuikit.com/components/select).
- A plain hex text field. Use an [Input](https://shadcnuikit.com/components/input).

**Agent notes**

- Import from `@/components/ui/color-picker`. The exports are `ColorPicker`, `ColorPickerArea`, `ColorPickerAreaCanvas`, `ColorPickerAreaThumb`, `ColorPickerSlider`, `ColorPickerSliderThumb`, `ColorPickerInput`, `ColorPickerChannelInput`, `ColorPickerSwatch`, `ColorPickerEyeDropper`, `ColorPickerSwatches`, `ColorPickerSwatchItem` and `createColorPickerController`.
- The value is a CSS color string, not an object. `details.color` in `onValueChange` holds the parsed color for `@ui-sdk/core/color` helpers like `formatColor`.
- `value` and `defaultValue` are shown as passed until the first change. Write them in the same syntax as `format`, or the input switches syntax on the first drag.
- To switch the format of a controlled value, convert it with `parseColor` and `formatColor` from `@ui-sdk/core/color` before passing the new `format`.
- Outside HSV and HSL, for example in OKLCH or sRGB, add `ColorPickerAreaCanvas` and `ColorPickerAreaThumb` inside `ColorPickerArea`. Without a canvas the area has no background.
- Save with `onValueCommit`, not `onValueChange`, which fires on every pixel of a drag.

**Resources**

- Markdown: [/docs/components/color-picker.md](https://shadcnuikit.com/docs/components/color-picker.md)
- Variants: [Color Picker components](https://shadcnuikit.com/components/color-picker), 6 free examples
- Install: `npx shadcn@latest add @shadcnuikit/color-picker1`
- MCP: call `get_item_code` with `color-picker1` from the [MCP Server](https://shadcnuikit.com/docs/mcp-server)
- Full index for agents: [llms.txt](https://shadcnuikit.com/llms.txt)

Source: https://shadcnuikit.com/docs/components/color-picker
More from Shadcn UI Kit: [llms.txt](https://shadcnuikit.com/llms.txt)