# react-color-palette

> 🎨 Lightweight Color Picker component for React.

Latest version **7.3.1** (published 2025-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-color-palette
pnpm add react-color-palette
yarn add react-color-palette
bun add react-color-palette
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.3.1 |
| Published | 2025-08-07 |
| First published | 2020-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 56.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 344 |
| Author | Wondermarin |
| Maintainers | wondermarin |
| Keywords | react, react-component, color-palette, color palette, color-picker, color picker, color, picker |

## Links

- npm: https://www.npmjs.com/package/react-color-palette
- Repository: https://github.com/Wondermarin/react-color-palette
- Homepage: https://github.com/Wondermarin/react-color-palette#readme
- Issues: https://github.com/Wondermarin/react-color-palette/issues
- npm.io page: https://npm.io/package/react-color-palette

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 7.3.1 (latest) — 2025-08-07
- 7.3.0 — 2024-09-13
- 7.2.2 — 2024-07-30
- 7.2.1 — 2024-07-12
- 7.2.0 — 2024-06-27
- 7.1.1 — 2024-04-10
- 7.1.0 — 2023-09-07
- 7.0.4 — 2023-08-12
- 7.0.3 — 2023-08-09
- 7.0.2 — 2023-08-04
- 7.0.1 — 2023-08-04
- 7.0.0 — 2023-08-03
- 6.2.0 — 2021-11-11
- 6.1.0 — 2021-07-22
- 6.0.0 — 2021-06-26
- … 21 more at https://npm.io/package/react-color-palette/versions

## README

<div align="center">
  <p>
    <img alt="react-color-palette" src="https://github.com/Wondermarin/react-color-palette/raw/main/public/logo.png" width="128px" height="128px" />
  </p>
  <p>🎨 Lightweight &lt;ColorPicker /&gt; component for <a href="https://github.com/facebook/react">React</a>.</p>
  <p>
    <a href="https://www.npmjs.com/package/react-color-palette">
      <img alt="npm" src="https://badgen.net/npm/v/react-color-palette?color=561ecb" />
    </a>
    <a href="https://www.npmjs.com/package/react-color-palette">
      <img alt="downloads" src="https://badgen.net/npm/dw/react-color-palette?color=561ecb" />
    </a>
    <a href="https://bundlephobia.com/result?p=react-color-palette">
      <img alt="size" src="https://badgen.net/bundlephobia/minzip/react-color-palette@latest?color=561ecb" />
    </a>
  </p>
  <p>
    <img src="https://github.com/Wondermarin/react-color-palette/raw/main/public/demo.apng" />
  </p>
</div>

## Installation

### yarn
```sh
yarn add react-color-palette
```

### npm
```sh
npm install react-color-palette
```

## Usage

```tsx
import { ColorPicker, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("#561ecb");

  return <ColorPicker color={color} onChange={setColor} />;
}
```

## Examples

### Usage <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb">`rgb()`</a> in <a href="#usecolor">`useColor()`</a>
```tsx
import { ColorPicker, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("rgb(86 30 203)");

  return <ColorPicker color={color} onChange={setColor} />;
}
```

### Usage <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/named-color">`<named-color>`</a> in <a href="#usecolor">`useColor()`</a>
```tsx
import { ColorPicker, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("cyan");

  return <ColorPicker color={color} onChange={setColor} />;
}
```

### Custom Layout
```tsx
import { Saturation, Hue, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("hsl(120 100% 50% / .5)");

  return (
    <div className="custom-layout">
      <Saturation height={300} color={color} onChange={setColor} />
      <Hue color={color} onChange={setColor} />
    </div>
  );
}
```

### HEX input only
```tsx
import { ColorPicker, useColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("#123123");

  return <ColorPicker hideInput={["rgb", "hsv"]} color={color} onChange={setColor} />
}
```

### onChangeComplete optional callback
```tsx
import { ColorPicker, useColor, type IColor } from "react-color-palette";
import "react-color-palette/css";

export function App() {
  const [color, setColor] = useColor("#123123");

  const onChangeComplete = (color: IColor) => localStorage.setItem("color", color.hex);

  return <ColorPicker hideInput={["rgb", "hsv"]} color={color} onChange={setColor} onChangeComplete={onChangeComplete} />
}
```

## API

### `<ColorPicker />`
<p>The main component, which includes: <a href="#saturation">&lt;Saturation /&gt;</a>, <a href="#hue">&lt;Hue /&gt;</a>, <a href="#alpha">&lt;Alpha /&gt;</a> and &lt;Fields /&gt; components for instant use.<br />If you need a custom layout, then you can use <a href="#saturation">&lt;Saturation /&gt;</a>, <a href="#hue">&lt;Hue /&gt;</a> and <a href="#alpha">&lt;Alpha /&gt;</a> components separately, which are also exported from the library.</p>

<table>
  <tr>
    <th>Prop</th>
    <th>Type</th>
    <th>Default</th>
    <th>Description</th>
  </tr>
  <tr>
    <td>height</td>
    <td>number</td>
    <td>200</td>
    <td>Height of the <a href="#saturation">Saturation</a> component in pixels.</td>
  </tr>
  <tr>
    <td>hideAlpha</td>
    <td>boolean</td>
    <td>false</td>
    <td>Hides the <a href="#alpha">Alpha</a> component.</td>
  </tr>
  <tr>
    <td>hideInput</td>
    <td>(keyof <a href="#icolor">IColor</a>)[] | boolean</td>
    <td>false</td>
    <td>If boolean: hides all inputs if true or displays all inputs if false. If array: hides all inputs listed in the array.</td>
  </tr>
  <tr>
    <td>color</td>
    <td><a href="#icolor">IColor</a></td>
    <td></td>
    <td>Current <a href="#icolor">color</a>.</td>
  </tr>
  <tr>
    <td>disabled</td>
    <td>boolean</td>
    <td>false</td>
    <td>Disables interactivity.</td>
  </tr>
  <tr>
    <td>onChange</td>
    <td>Function</td>
    <td></td>
    <td>Сallback function will be fired when <a href="#icolor">color</a> changes.</td>
  </tr>
  <tr>
    <td>onChangeComplete</td>
    <td>Function</td>
    <td></td>
    <td>Callback function will be fired when the interaction is complete with the color picker.</td>
  </tr>
</table>

### `<Saturation />`

<table>
  <tr>
    <th>Prop</th>
    <th>Type</th>
    <th>Default</th>
    <th>Description</th>
  </tr>
  <tr>
    <td>height</td>
    <td>number</td>
    <td></td>
    <td>Height of the saturation element in pixels.</td>
  </tr>
  <tr>
    <td>color</td>
    <td><a href="#icolor">IColor</a></td>
    <td></td>
    <td>Current <a href="#icolor">color</a>.</td>
  </tr>
  <tr>
    <td>disabled</td>
    <td>boolean</td>
    <td>false</td>
    <td>Disables interactivity.</td>
  </tr>
  <tr>
    <td>onChange</td>
    <td>Function</td>
    <td></td>
    <td>Сallback function will be fired when <a href="#icolor">color</a> changes.</td>
  </tr>
  <tr>
    <td>onChangeComplete</td>
    <td>Function</td>
    <td></td>
    <td>Callback function will be fired when the interaction is complete with the saturation picker.</td>
  </tr>
</table>

### `<Hue />`

<table>
  <tr>
    <th>Prop</th>
    <th>Type</th>
    <th>Default</th>
    <th>Description</th>
  </tr>
  <tr>
    <td>color</td>
    <td><a href="#icolor">IColor</a></td>
    <td></td>
    <td>Current <a href="#icolor">color</a>.</td>
  </tr>
  <tr>
    <td>disabled</td>
    <td>boolean</td>
    <td>false</td>
    <td>Disables interactivity.</td>
  </tr>
  <tr>
    <td>onChange</td>
    <td>Function</td>
    <td></td>
    <td>Сallback function will be fired when <a href="#icolor">color</a> changes.</td>
  </tr>
  <tr>
    <td>onChangeComplete</td>
    <td>Function</td>
    <td></td>
    <td>Callback function will be fired when the interaction is complete with the hue picker.</td>
  </tr>
</table>

### `<Alpha />`

<table>
  <tr>
    <th>Prop</th>
    <th>Type</th>
    <th>Default</th>
    <th>Description</th>
  </tr>
  <tr>
    <td>color</td>
    <td><a href="#icolor">IColor</a></td>
    <td></td>
    <td>Current <a href="#icolor">color</a>.</td>
  </tr>
  <tr>
    <td>disabled</td>
    <td>boolean</td>
    <td>false</td>
    <td>Disables interactivity.</td>
  </tr>
  <tr>
    <td>onChange</td>
    <td>Function</td>
    <td></td>
    <td>Сallback function will be fired when <a href="#icolor">color</a> changes.</td>
  </tr>
  <tr>
    <td>onChangeComplete</td>
    <td>Function</td>
    <td></td>
    <td>Callback function will be fired when the interaction is complete with the alpha picker.</td>
  </tr>
</table>

### `useColor()`

<table>
  <tr>
    <th>Arg</th>
    <th>Type</th>
    <th>Default</th>
    <th>Description</th>
  </tr>
  <tr>
    <td>initialColor</td>
    <td><a href="#tcolor">TColor</a></td>
    <td></td>
    <td>Initial <a href="#tcolor">сolor</a>.</td>
  </tr>
</table>

### `TColor`
<p>Value can be specified using one of the methods listed below:</p>

- <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/named-color">`<named-color>`</a>
- <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color">`<hex-color>`</a>
- <a href="https://en.wikipedia.org/wiki/SRGB">sRGB</a> color space: <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl">`hsl()`</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb">`hwb()`</a> or <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb">`rgb()`</a>

### `IColor`

<table>
  <tr>
    <th>Field</th>
    <th>Type</th>
  </tr>
  <tr>
    <td>hex</td>
    <td>string</td>
  </tr>
  <tr>
    <td>rgb</td>
    <td><a href="#icolorrgb">IColorRgb</a></td>
  </tr>
  <tr>
    <td>hsv</td>
    <td><a href="#icolorhsv">IColorHsv</a></td>
  </tr>
</table>

### `IColorRgb`

<table>
  <tr>
    <th>Field</th>
    <th>Type</th>
  </tr>
  <tr>
    <td>r</td>
    <td>number</td>
  </tr>
  <tr>
    <td>g</td>
    <td>number</td>
  </tr>
  <tr>
    <td>b</td>
    <td>number</td>
  </tr>
    <tr>
    <td>a</td>
    <td>number</td>
  </tr>
</table>

### `IColorHsv`

<table>
  <tr>
    <th>Field</th>
    <th>Type</th>
  </tr>
  <tr>
    <td>h</td>
    <td>number</td>
  </tr>
  <tr>
    <td>s</td>
    <td>number</td>
  </tr>
  <tr>
    <td>v</td>
    <td>number</td>
  </tr>
    <tr>
    <td>a</td>
    <td>number</td>
  </tr>
</table>

## License

<p>Code released under the <a href="https://github.com/Wondermarin/react-color-palette/blob/master/LICENSE">MIT</a> license.</p>

---
_Source: https://npm.io/package/react-color-palette · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
