opacity
Turn on alpha and the picker gets an opacity slider, with the alpha in every format. Here it sets how much of the paint shows behind this section.
A color picker for React: hex, rgb, hsl and oklch, an eyedropper and full keyboard support. One shadcn item, no dependencies.
Up to four colors in one row, each its own picker. The first one paints this page; make the others yours and the whole page takes them, the darkest in the shadows.
Turn on alpha and the picker gets an opacity slider, with the alpha in every format. Here it sets how much of the paint shows behind this section.
The eyedropper where the browser has one, a copy button and four formats. Click anywhere on the paint around them to take its color: that part works in every browser.
The swatch as you get it: it opens into the picker.
Every part of the picker answers the keys, and a screen reader hears what changed: “Saturation 40%, Brightness 80%”, “Hue 48°”. Try it here — this panel paints the page.
| ←→ | Saturation in the area by 1%, hue on its slider by 1°, opacity by 1% |
|---|---|
| ↑↓ | Brightness in the area |
| Shift | With an arrow: ten steps at once |
| HomeEnd | A slider to its ends |
| Tab | Value field, area, hue, format, eyedropper, copy, in that order |
| EnterSpace | Open the picker from its swatch |
| Esc | Revert the value field, then close and return to the swatch |
The swatch morphs into the panel on springs. Turn this on, or the system setting, and it simply appears.
One command with the shadcn CLI, then use it like an input.
The shadcn CLI copies six files into your project: the picker, its CSS, the color math, the morph, a hook for the agent bridge and a small spring helper. No package is added.
Controlled like an input: give it any CSS color and take back a string in the format the switch shows, oklch to begin with.
"use client";
import { useState } from "react";
import { ColorPicker } from "@/components/ui/color-picker/color-picker";
export function AccentField() {
const [accent, setAccent] = useState("oklch(62% 0.19 255)");
// The swatch opens the picker; `name` sends the value with a native form.
return (
<ColorPicker
color={accent}
onChange={setAccent}
defaultFormat="oklch"
name="accent"
labels={{ open: "Pick accent" }}
/>
);
}For a set of colors, the palette holds one to four of them, each its own picker, and brings the picker along if you skipped step 1.
About the registry, oklch, the eyedropper, the palette, clipping and labels.
A color picker is something you end up restyling. The shadcn CLI copies its source into your project, so the markup, the CSS and the labels are yours to change, with nothing to keep upgrading.
The swatch shows them as given. The area is sRGB, so the first move of a handle keeps the lightness and hue and lowers the chroma until the color fits; the output is always one of the four formats you allow.
The button in the panel appears only where the browser has the EyeDropper API, Chromium browsers today; in Safari and Firefox it is not rendered at all, rather than shown disabled. Picking from your own image works everywhere: draw it on a canvas and read the pixel, or work it out from your own data, as the paint above does: its color comes from the frame and the ramp, not from a screenshot.
Add the palette: one to four swatches in a row, each a full picker, with a button to add a color and Delete to remove one. It takes and gives back an array in one format, sends every color with a form under one name, and is a single Tab stop with the arrows inside.
The panel is not portalled, so it keeps your theme and works inside iframes, but a container with overflow: hidden clips it. Give that container overflow: visible, or place the picker outside it. Near the viewport edges the panel flips up or left on its own.
Pass labels: every string the picker says or announces is there, from the swatch button to “Copied”. Anything you leave out keeps its English default.
