Skip to content

Color picker

A swatch that grows into a picker with format morphing, eyedropper, saved swatches, and contrast readout.

InputsNew
npx shadcn@latest add @silicon-ui/color-picker

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/color-picker

Manually

  1. Install the dependencies

    npm install lucide-react motion
  2. Copy 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
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { ColorPicker } from "@/components/silicon-ui/color-picker/color-picker";

API reference

PropTypeDefault
value

Any color the picker can read: hex, rgb(), hsl(), or oklch().

string—
defaultValuestring"#2F6BFF"
onValueChange

Receives the color as hex, with two alpha digits when it is not opaque.

(hex: string) => void—
background

The background the color will sit on, for the contrast readout.

string"#FFFFFF"
label

Name shown on the swatch, such as "Accent".

string"Color"
swatchesColorSwatch[]—
defaultSwatchesColorSwatch[]—
onSwatchesChange(swatches: ColorSwatch[]) => void—
maxSwatches

Most saved swatches. Saving past it drops the oldest.

number7
defaultFormatColorFormat

"hex""rgb""hsl""oklch"

"hex"
classNamestring—

Dependencies

npm
lucide-reactmotion
Registry
silicon-motion-tokenstext-morph