React Color Picker
A glass React color picker with a saturation area, hue and opacity sliders, typed hex, RGB and HSL values, swatches and the screen eyedropper.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/color-picker.jsonChoose your accent
HexRGBHSL
#6d4aff
ColorPickerColorFielddefaultColorPickerLabels- +1 more
Using it in a form? See the react-hook-form and zod recipe.
Picker
Drag the area or use the arrow keys on it (Shift for bigger steps). The value is always emitted as hex.
HexRGBHSL
#6d4aff
import { useState } from "react";
import { ColorPicker } from "@/components/sheenui/color-picker/color-picker";
// Package build (after the first npm release, or a packed tarball): import { ColorPicker } from "@sheenui/theme";
export function Example() {
const [color, setColor] = useState("#6d4aff");
return (
<ColorPicker
value={color}
onValueChange={setColor}
swatches={[{ value: "#6d4aff", label: "Violet" }, "#3b82f6", "#10b981", "#f59e0b"]}
aria-label="Accent color"
/>
);
}Files to copy
7 folders · 12 files · 4 packages
- From
theme/src/ components/color-picker/components/date-picker/picker-surface.tsxcomponents/status-icons/hooks/{use-controllable.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{cn.ts, field-size.ts, form.ts, math.ts, popup-motion.ts, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/color-picker.jsonRegistry item: color-picker. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Color field
A hex field with a swatch that opens the picker in a glass popover (a bottom sheet on phones). Type a hex straight into the field, or submit it with name.
Used for buttons and links.
import { useState } from "react";
import { ColorField } from "@/components/sheenui/color-picker/color-picker";
// Package build (after the first npm release, or a packed tarball): import { ColorField } from "@sheenui/theme";
const SWATCHES = ["#6d4aff", "#3b82f6", "#06b6d4", "#10b981", "#84cc16", "#f59e0b", "#ef4444", "#ec4899"];
export function Example() {
const [brand, setBrand] = useState("#6d4aff");
return (
<ColorField
label="Brand color"
value={brand}
onValueChange={setBrand}
swatches={SWATCHES.slice(0, 8)}
alpha={false}
name="brand"
description="Used for buttons and links."
/>
);
}Hex only, no opacity
Trim it down: one format, no opacity, no swatches.
import { ColorPicker } from "@/components/sheenui/color-picker/color-picker";
// Package build (after the first npm release, or a packed tarball): import { ColorPicker } from "@sheenui/theme";
export function Example() {
return (
<ColorPicker defaultValue="#22c55e" formats={["hex"]} alpha={false} />
);
}ColorPicker props
ColorPickerLabels keys and English defaults (25)
ColorField props
Keyboard
Accessibility
- The color area is a 2-D slider; the area, hue and opacity sliders and each channel input have a name and a spoken value ("Saturation 64%, brightness 100%").
- In ColorField, type a hex value and press Enter or leave the field to apply it (Escape discards); description and error are linked with aria-describedby.
- Copying announces the copied value politely. The color graphics opt out of forced colors (they are content, like an image); the controls around them keep system colors.
All exports on this page
ColorField— A hex text field with a swatch button that opens the full ColorPicker (a glass popover from 640px up, a bottom sheet on phones).ColorPicker— A colour picker: a saturation / brightness area, hue and opacity sliders, typed values (hex, RGB or HSL), swatches, copy.defaultColorPickerLabels— The English strings of ColorPicker.
When to use the color picker
- Use it as a hex, RGB and HSL color picker in a theme editor or brand settings screen where people tune an accent color with the saturation and brightness area, a hue slider and an opacity slider, then copy the result.
- Use it for design-tool style inputs such as a highlight color for a note, a chart series color or a label color, where presets via the swatches prop give one-click choices beside free selection.
- Use ColorField when the picker belongs in a form: it shows a swatch plus a hex text field and opens the picker as a popover from 640px up, or as a bottom drawer on phones.
- Skip it when users only choose from five or six fixed brand colors; a RadioGroup with swatch cards or a SegmentedControl is simpler and needs no continuous color space or typed values.
- Pair it with Popover for custom trigger layouts, the label, description and error props of ColorField for the name and message, and Slider or Switch next to it for related theme settings like contrast.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .