Component reference
ColorPicker
Edit two brand colors with a live visual preview.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
#5B55E7 · #0EA5E9
A live preview of the two selected tokens. The picker reports uppercase #RRGGBB values.
Width adapts to the available space
"use client";
import { useState } from "react";
import { ColorPicker, DEFAULT_COLOR_PICKER_PRESETS, Button } from "@pimolu/react";
const brandPresets = DEFAULT_COLOR_PICKER_PRESETS;
function BrandStudio() {
const [brand, setBrand] = useState("#5B55E7");
const [accent, setAccent] = useState("#0EA5E9");
return (
<div
className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))] gap-6 min-w-0"
>
<div className="grid gap-5 min-w-0">
<ColorPicker
label="Brand color"
value={brand}
onValueChange={setBrand}
presets={brandPresets}
/>
<ColorPicker
label="Accent color"
value={accent}
onValueChange={setAccent}
presets={brandPresets}
size="sm"
/>
<div className="flex flex-wrap items-center gap-3 min-w-0">
<Button
type="button"
size="sm"
appearance="ghost"
onClick={() => {
setBrand("#5B55E7");
setAccent("#0EA5E9");
}}
>
Reset palette
</Button>
</div>
</div>
<div
className="min-w-0 rounded-lg border border-border p-6 grid gap-5 min-w-0"
style={{
borderTop: `4px solid ${brand}`
}}
>
<div className="flex flex-wrap items-center gap-3 min-w-0">
<span
aria-hidden="true"
style={{
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
width: 40,
height: 40,
borderRadius: 12,
background: brand,
color: "#ffffff",
fontWeight: 700,
}}
>P</span>
<div>
<strong style={{ color: brand }}>Pimolu Studio</strong>
<p className="text-sm text-muted leading-relaxed">
{brand} · {accent}
</p>
</div>
</div>
<p className="text-sm text-muted leading-relaxed">
A live preview of the two selected tokens. The picker reports
uppercase #RRGGBB values.
</p>
<div className="flex flex-wrap items-center gap-3 min-w-0">
<Button
type="button"
size="sm"
style={{
background: brand,
borderColor: brand,
color: "#ffffff",
}}
>
Start a project
</Button>
<Button
type="button"
size="sm"
appearance="outline"
style={{
color: accent,
borderColor: accent,
}}
>
View work
</Button>
</div>
</div>
</div>
);
}
export function DemoExample() {
return (<BrandStudio />);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Sizes
sm, md and lg scale the trigger, the swatch and the value together.
Presets
The presets prop accepts any readable array; invalid entries are filtered out and each swatch has an accessible name.
States
An external error marks the control invalid; read-only keeps the value inspectable; disabled closes every entry point.
Usage
Use presets for suggestions and the editable color value for additional choices.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluColorPickerProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
value | string | undefined | — | Controlled hex color, for example `"#5B55E7"`. |
defaultValue | string | undefined | `"#5B55E7"` | Initial hex color when uncontrolled. Defaults to `"#5B55E7"`. |
onValueChange | ((value: string) => void) | undefined | — | Called with the next color, normalized to an uppercase `#RRGGBB` string. |
presets | readonly string[] | undefined | a small cross-theme palette | Preset swatches. Each entry must be a valid hex color. Defaults to a small cross-theme palette. |
disabled | boolean | undefined | false | Disable the trigger entirely. |
readOnly | boolean | undefined | false | Keep the value visible but prevent every change. |
label | string | undefined | — | Visible label, also used to name the trigger. |
error | ReactNode | — | Error text; also marks the control as invalid. |
size | PimoluColorPickerSize | undefined | "md" | Visual size. Defaults to "md". |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
children | ReactNode | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLDivElement> | undefined | — | Standard React/HTML attribute. |
valuestring | undefinedNo default extracted.
Controlled hex color, for example `"#5B55E7"`.
defaultValuestring | undefinedDefault: `"#5B55E7"`
Initial hex color when uncontrolled. Defaults to `"#5B55E7"`.
onValueChange((value: string) => void) | undefinedNo default extracted.
Called with the next color, normalized to an uppercase `#RRGGBB` string.
presetsreadonly string[] | undefinedDefault: a small cross-theme palette
Preset swatches. Each entry must be a valid hex color. Defaults to a small cross-theme palette.
disabledboolean | undefinedDefault: false
Disable the trigger entirely.
readOnlyboolean | undefinedDefault: false
Keep the value visible but prevent every change.
labelstring | undefinedNo default extracted.
Visible label, also used to name the trigger.
errorReactNodeNo default extracted.
Error text; also marks the control as invalid.
sizePimoluColorPickerSize | undefinedDefault: "md"
Visual size. Defaults to "md".
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
childrenReactNodeNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLDivElement> | undefinedNo default extracted.
Standard React/HTML attribute.
Accessibility
- Give color values readable names and verify contrast after customization; a swatch alone is not a label.