Color Picker
Designer-grade color picker. Saturation × value pad, hue slider, alpha track with checkerboard, format tabs for hex, rgb, and hsl, one-click pills for currentColor, transparent, and inherit, recent-colors strip, and live WCAG contrast badges. Controlled. Emits a CSS color string: #rrggbb, #rrggbbaa, or one of the special keywords.
Install
Pull Color Picker from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { ColorPicker } from "@brika/clay";import { ColorPicker } from "@brika/clay/components/color-picker";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
import { ColorPicker } from '@brika/clay/components/color-picker';
import { useState } from 'react';
/** Default picker, full chrome, controlled. */
export default function ColorPickerDefaultDemo() {
const [color, setColor] = useState('#3b82f6');
return <ColorPicker value={color} onChange={setColor} />;
}Color Picker, every way
currentColor
`currentColor` keyword, the trigger swatch picks up the surrounding text color.
In a field
Inside a `<Field>` with a label, the form-pattern usage.
In a popover
Inside a popover, with a `<Button>` trigger that previews the value.
No alpha
Opaque picker, alpha controls and the alpha column are hidden.
No special pills
Without the special-keyword pills, useful when the slot must be a real color.
Recent colors
Recent-colors strip with a tiny in-memory store, plus a "Save" button.
Accessibility
- The saturation/value pad and hue slider expose
role="slider"witharia-valuetextso screen readers announce the current position; both also accept arrow-key navigation. - Each numeric input field is labelled (R / G / B / A or H / S / L / A) and reflects the current value; editing one commits to the same color and updates the others.
- Eyedropper is hidden when
window.EyeDropperis unavailable; consumers should not assume it is always present.
Theme tokens
Every CSS variable Color Picker reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Color Picker
without touching component code.
Color Picker tokens
13 tokens--color-picker-surface-containercolorvar(--popover)components.colorPicker.surfaceContainerBackground of the picker panel.
--color-picker-surface-labelcolorvar(--popover-foreground)components.colorPicker.surfaceLabelDefault foreground inside the picker panel.
--color-picker-bordercolorvar(--border)components.colorPicker.borderColor of the panel and inner control borders.
--color-picker-markercolor#ffffffcomponents.colorPicker.markerRing color around the sat/val pad cursor and slider thumbs. Defaults to white so the marker is visible over both light and dark colors.
--color-picker-checkercolorvar(--muted)components.colorPicker.checkerColor of the dark cells in the alpha-track checkerboard. The light cells are white.
--color-picker-pad-radiusradius0.5remcomponents.colorPicker.padRadiusCorner radius of the saturation/value pad. Set to `0` for square / brutalist looks.
--color-picker-track-radiusradius9999pxcomponents.colorPicker.trackRadiusCorner radius of the hue and alpha slider tracks and their markers. Defaults to a full pill; set lower for square / brutalist looks.
--color-picker-radiusradiusvar(--radius-surface)components.colorPicker.radiusColorPicker panel corner radius.
--color-picker-border-widthborder-width1pxcomponents.colorPicker.borderWidthBorder width on the color-picker. Set non-zero for outline-style variants.
--color-picker-border-styleborder-stylesolidcomponents.colorPicker.borderStyleBorder style on the color-picker (`solid`, `dashed`, `double`, `none`).
--color-picker-shadowshadowvar(--shadow-overlay)components.colorPicker.shadowColorPicker panel elevation.
--color-picker-durationdurationvar(--motion-standard-duration)components.colorPicker.durationTransition duration for color-picker state changes.
--color-picker-easingeasingvar(--motion-standard-easing)components.colorPicker.easingTransition easing for color-picker state changes.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.colorPicker, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"colorPicker": {
"radius": "var(--radius-surface)"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-color-picker-…) — see the
chips on each token row.
API reference
Props specific to Color Picker. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<ColorPicker />
10 props- (next: string) => void
No description.
- string
No description.
- string
No description.
- (value: string) => voidCalled when the user clicks the swatch to save its value to recents.
- () => voidRender an "✕" close button on the right edge of the header.
- recentColorsdefault
[]readonly string[]Recently-picked colors shown beneath the inputs. - showAlphadefault
truebooleanDefaults totrue. Set false for opaque-only pickers. - showContrastdefault
truebooleanDefaults totrue. - showEyedropperdefault
truebooleanDefaults totrue. Auto-hidden whenwindow.EyeDropperis unavailable. - specialKeywordsdefault
SPECIAL_KEYWORDSreadonly SpecialKeyword[]Defaults to the full set; pass[]to hide the special pills.
<RecentStrip />
2 props- readonly string[]
No description.
- (value: string) => void
No description.
<SpecialPills />
3 props- Lowercase<SpecialKeyword> | null
No description.
- readonly SpecialKeyword[]
No description.
- (keyword: SpecialKeyword) => void
No description.