Skip to content

Components

Color Picker

A colour field with a popover: area, hue, formats, eyedropper, swatches and contrast.

Customize
Ombelle · light

Installation

Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.

pnpm dlx @ombelle-ui/cli@1.1.2 add color-picker

Adds components/ui/color-picker.tsx and installs react, @radix-ui/react-popover, @radix-ui/react-slider, clsx, tailwind-merge, lucide-react with lifecycle scripts disabled. This is a client component.

In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.

Usage

example.tsx
import { ColorPicker, ColorPickerPair } from '@/components/ui/color-picker'
const swatches = [{ label: 'Rose', value: 'oklch(0.55 0.22 6)' }, { label: 'Ink', value: 'oklch(0.22 0.012 275)' }]
export function Example(){return <div style={{ display: "grid", gap: "1rem" }}><ColorPickerPair label="Primary"><ColorPicker mode="light" defaultValue="oklch(0.55 0.22 6)" swatches={swatches} contrastWith="oklch(0.99 0 0)" contrastLabel="primary foreground" /><ColorPicker mode="dark" defaultValue="oklch(0.7 0.18 6)" swatches={swatches} contrastWith="oklch(0.16 0.01 275)" contrastLabel="primary foreground" /></ColorPickerPair><ColorPicker label="Accent" defaultFormat="hex" defaultValue="#1d4ed8" /></div>}

API and states

API
ColorPicker (value, defaultValue, onValueChange, onInvalid, label, placeholder, format, swatches, formats, contrastWith, contrastLabel, eyeDropper, mode, container), ColorPickerSwatches, ColorPickerPair (label)
Minimum states
Valid, invalid, empty with placeholder, open, disabled, focus
Native basis
Reviewed Radix Popover and Slider; Base UI Popover and Slider in the Base UI edition
Styles
Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.