UIComponentsReact
A row of color swatches of which one is checked, such as a palette.
Built on the headless Color Swatch Picker.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/color-swatch-picker.jsonIt also adds utils. The app needs its setup first: Installation.
Usage
Write one ColorSwatchPickerItem per color, with value the item's color. The checked item gets a ring with a gap and the focused one the radio's focus ring. The radio group, its arrow keys, the names of the colors and the form value come from the headless Color Swatch Picker. Inside a Color Picker it sets the picker's color.
import { ColorSwatchPicker, ColorSwatchPickerItem } from '@/components/ui/color-swatch-picker'Examples
Default
Six colors with the blue one checked at first.
shadcn/ui has no Color Swatch Picker, so this item takes Base UI's component ID as its slug and one name per Base UI part. Its items are 24px, drawn over a checkerboard like Color Swatch.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Color Swatch Picker's API reference.