ColorPicker is an input component to select a color.

import { ColorPicker } from 'primereact/colorpicker';

ColorPicker is used as a controlled input with value and onChange properties.

<ColorPicker value={color} onChange={(e) => setColor(e.value)} />


ColorPicker is displayed as a popup by default, add inline property to customize this behavior.

<ColorPicker value={color} onChange={(e) => setColor(e.value)} inline />

Default color format to use in value binding is hex and other possible values can be rgb and hsb using the format property.


<ColorPicker format="hex" value={colorHEX} onChange={(e) => setColorHEX(e.value)} />
<ColorPicker format="rgb" value={colorRGB} onChange={(e) => setColorRGB(e.value)} />
<ColorPicker format="hsb" value={colorHSB} onChange={(e) => setColorHSB(e.value)} />

When disabled is present, the element cannot be edited and focused.

<ColorPicker disabled />

Screen Reader

Specification does not cover a color picker yet and using a semantic native color picker is not consistent across browsers so currently component is not compatible with screen readers. In the upcoming versions, text fields will be introduced below the slider section to be able to pick a color using accessible text boxes in hsl, rgba and hex formats.

Closed State Keyboard Support of Popup ColorPicker

tabMoves focus to the color picker button.
spaceOpens the popup and moves focus to the color slider.

Popup Keyboard Support

enterSelects the color and closes the popup.
spaceSelects the color and closes the popup.
escapeCloses the popup, moves focus to the input.

Color Picker Slider

arrow keysChanges color.

Hue Slider

up arrowdown arrowChanges hue.