Color Picker
FormVisual color selection input with hue/saturation controls and hex value entry.
Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.
"use client";
import { ColorPicker } from "@dashboardpack/core/components/ui/color-picker";
import { useState } from "react";
export default function ColorPickerExample() {
const [color, setColor] = useState("#0d9488");
return (
<div className="space-y-4">
<p className="text-sm font-medium">Brand color</p>
<ColorPicker
value={color}
onChange={setColor}
presets={["#0d9488", "#2563eb", "#9333ea", "#ea580c"]}
/>
<div
className="h-16 w-48 rounded-lg border"
style={{ backgroundColor: color }}
role="img"
aria-label={`Selected color ${color}`}
/>
<ColorPicker value={color} onChange={setColor} disabled />
</div>
);
}Usage
Store a six-digit hexadecimal color including the # prefix. Supply brand presets, or pass an empty array to hide preset swatches. Use semantic tokens for the surrounding interface.
import { ColorPicker } from "@dashboardpack/core/components/ui/color-picker";Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.
API reference
Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.
| Prop | Type / Default | Description |
|---|---|---|
| value | stringDefault: required | Current #rrggbb color. |
| onChange | (color: string) => voidDefault: required | Receives the next color. |
| presets | string[]Default: 10 standard colors | Preset hex swatches. |
| disabled | booleanDefault: false | Prevent editing. |