react-color-palette is a lightweight, performant React component library providing a comprehensive color picker interface. Currently stable at version 7.3.1, it receives regular maintenance and feature updates, with minor releases typically occurring every few months. Its core strength lies in its flexibility, offering a complete `<ColorPicker />` component for immediate use, alongside individual `<Saturation />`, `<Hue />`, and `<Alpha />` components for creating highly customized color picker layouts. It fully supports TypeScript, shipping with declaration files for all its components and hooks like `useColor`. Key features include robust support for various CSS color formats (HEX, RGB, HSL, named colors) in the `useColor` hook, an `onChangeComplete` callback for handling final color selections, and options to customize input visibility or disable the picker entirely. This makes it a versatile choice for applications requiring intuitive and customizable color selection capabilities within a React environment.
npm install react-color-paletteVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the basic setup of the ColorPicker component, including state management with `useColor`, importing necessary CSS, and handling both continuous color changes and final selection with `onChangeComplete`.
Ensure `import 'react-color-palette/css';` is present in your application's entry point or the component where the color picker is used.
Refactor your code to ensure `useColor` is called unconditionally within a functional component or custom hook.
Verify behavior if you have highly customized event handling or accessibility implementations interacting directly with the color picker's DOM elements.
Ensure your bundler configuration (e.g., `webpack.config.js`) is set up to respect `sideEffects` in `package.json` for `node_modules`. For Webpack, this usually means `"sideEffects": true` in your `package.json` and a default `module.rules` setup.
Add `import 'react-color-palette/css';` to your component file or global stylesheet entry point.
Ensure `useColor` is only called inside a React functional component or another custom hook.
Always initialize `useColor` with a valid default color value (e.g., `useColor('#000000')`). Ensure components consuming the color object handle potential `null` or `undefined` states if they can occur asynchronously.