Color Picker
Choose solid colors with an HSV area, hue and alpha controls, channel fields, presets, and composable popover support.
Color Picker provides the complete solid-color workflow in one panel. It keeps HSV as its working model while exposing HEX, RGB, and HSL fields, so switching the visible format never changes the selected color.
#d31510Import
Section titled “Import”import { ColorPicker } from "@zentara-co/zenos-ui";Controlled value
Section titled “Controlled value”Use value and onValueChange when another owner needs the selected color. Values are normalized to six-digit HEX while opaque and eight-digit HEX when alpha is below 100%.
const [color, setColor] = useState("#d31510"); <ColorPicker value={color} onValueChange={setColor} />;Use defaultValue for an uncontrolled picker. Three- and four-digit HEX inputs are accepted and normalized.
Formats
Section titled “Formats”The format switcher changes only the visible channel fields. onValueChange always receives HEX, regardless of whether the person edits HEX, RGB, or HSL. Control the switcher with format and onFormatChange, or seed it with defaultFormat.
Sizes and surface
Section titled “Sizes and surface”md is the complete 324px panel. sm is a compact 216px panel and omits the channel field row because it does not fit comfortably at that width. Use variant="plain" when the picker already sits inside a card, dialog, or settings surface.
Alpha and presets
Section titled “Alpha and presets”Alpha and preset colors are enabled by default. Set showAlpha={false} for opaque-only selection, showPresets={false} to remove the palette, or pass presets with application-owned HEX colors.
<ColorPicker showAlpha={false} presets={["#d31510", "#0f0f0f", "#f9f9f9"]} />Composition
Section titled “Composition”Passing children replaces the default layout. Every functional part remains connected to the root state, so parts can be dropped, reordered, or wrapped without adding visibility flags.
Popover
Section titled “Popover”The popover parts reuse Zenos Popover positioning, focus management, collision handling, and motion. The picker owns its card surface, so ColorPicker.Content adds positioning without drawing a second frame.
Color utilities
Section titled “Color utilities”The package exports normalizeColorHex, hexToHsva, hsvaToHex, hsvaToRgba, rgbaToHsva, hsvaToHsla, and hslaToHsva for applications that need the same conversion model outside the component.
Variants
cardplain Sizes
smmd ColorPicker.Root ColorPicker.Format ColorPicker.Preview ColorPicker.Area ColorPicker.Controls ColorPicker.HueSlider ColorPicker.AlphaSlider ColorPicker.Fields ColorPicker.Swatches ColorPicker.Popover ColorPicker.Trigger ColorPicker.Content ColorPicker.TriggerSwatch
API
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Controlled HEX color. |
defaultValue | string | #d31510 | Initial uncontrolled HEX color. |
onValueChange | (value: string) => void | — | Receives normalized six- or eight-digit HEX. |
format / defaultFormat | hex | hsl | rgb | hex | Controlled or initial channel-field format. |
onFormatChange | (format: ColorPickerFormat) => void | — | Runs when the visible channel format changes. |
size | sm | md | md | 216px compact panel or 324px complete panel. |
variant | card | plain | card | Draws the panel surface or inherits its surrounding surface. |
showAlpha / showInput / showPresets | boolean | true | Includes each optional part in the default composition. |
presets | readonly string[] | — | Application-owned HEX colors shown by the default swatch grid. |
disabled | boolean | false | Disables the area, rails, fields, format buttons, and presets. |
children | ReactNode | — | Replaces the default layout with a custom composition of picker parts. |
Swatches.label | ReactNode | Colors | Renames or removes the preset section label. |
Content side / align / offsets | Popover placement props | — | Positions the popover picker through the shared Popover behavior. |
native props | React.HTMLAttributes<HTMLDivElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |
Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props,
including className, style, aria-*, and data-*.
Accessibility
Section titled “Accessibility”The saturation and brightness area supports arrow keys, with Shift increasing the step. Hue and alpha use native range controls. Format and preset choices expose pressed state, every channel has an accessible name, and disabled state reaches every default interaction. Color is always returned as text rather than communicated by the swatch alone.