React ColorPicker

React ColorPicker

·

2 min read

React ColorPicker is an input component to select a color.

Setup

Refer to PrimeReact setup documentation for download and installation steps for your environment.

Import

import {ColorPicker} from 'primereact/colorpicker';

Getting Started

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

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

Formats

Default color format to use in value binding is "hex" and other possible values are "rgb" and "hsb". Example below has 3 colorpickers having default values with different formats.

<ColorPicker value={color1} onChange={(e) => setColor1(e.value)} />

<ColorPicker format="rgb" value={color2} onChange={(e) => setColor2(e.value)} />

<ColorPicker format="hsb" value={color3} onChange={(e) => setColor3(e.value)}/>

Theming

ColorPicker supports various themes featuring Material, Bootstrap, Fluent as well as your own custom themes via the Designer tool.

Resources

Visit the PrimeReact ColorPicker showcase for demos and documentation.