Color picker
A swatch that grows into a picker with format morphing, eyedropper, saved swatches, and contrast readout.
npx shadcn@latest add @silicon-ui/color-pickerInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/color-pickerManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/color-picker/color-picker.tsx
- components/silicon-ui/color-picker/color-picker.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/text-morph/text-morph.tsx
- components/silicon-ui/text-morph/text-morph.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
valueAny color the picker can read: hex, rgb(), hsl(), or oklch(). | string | — |
defaultValue | string | "#2F6BFF" |
onValueChangeReceives the color as hex, with two alpha digits when it is not opaque. | (hex: string) => void | — |
backgroundThe background the color will sit on, for the contrast readout. | string | "#FFFFFF" |
labelName shown on the swatch, such as "Accent". | string | "Color" |
swatches | ColorSwatch[] | — |
defaultSwatches | ColorSwatch[] | — |
onSwatchesChange | (swatches: ColorSwatch[]) => void | — |
maxSwatchesMost saved swatches. Saving past it drops the oldest. | number | 7 |
defaultFormat | ColorFormat
| "hex" |
className | string | — |