React Colorful is a highly optimized and lightweight color picker component designed for React and Preact applications. Currently stable at version 5.6.1, it provides a variety of color models including HEX, RGBA, HSLA, and HSVA, boasting a minimal bundle size (just 2.8 KB gzipped) and zero runtime dependencies. The library features a modern API leveraging React hooks and functional components, and comes with comprehensive TypeScript support. It prioritizes accessibility, adhering to WAI-ARIA guidelines, and offers full keyboard navigation and touch screen compatibility. A key differentiator is its significant performance and size advantage over alternatives like `react-color`, coupled with a tree-shakable architecture. Since v5, it has eliminated the need for external CSS imports, streamlining integration into any CSS-in-JS or component library environment. Releases are driven by feature enhancements and bug fixes, ensuring continuous improvement and stability.
npm install react-colorfulVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate the HexColorPicker component, manage its state using React hooks, and update the color dynamically. It also shows basic interactions.
Remove any `import 'react-colorful/dist/index.css';` statements from your codebase. The styles are now automatically included.
Update all imports to use named exports, e.g., `import { HexColorPicker } from 'react-colorful';`.Review and adjust your component's CSS rules. You might need to use more specific selectors or `!important` sparingly if absolutely necessary to override the component's internal styles.
Ensure color input strings for picker components follow valid CSS color notations (e.g., `rgb(100% 50% 25%)`, `hsl(100grad, 50%, 50%)`, `rgba(100% 50% 25% / 99%)`). Refer to CSS Color Module Level 4 specifications for details.
Use ES Module named imports: `import { HexColorPicker } from 'react-colorful';`Remove the line `import 'react-colorful/dist/index.css';` from your project. The component's styles are now embedded.
Ensure the `color` prop passed to each picker component matches its expected format. `HexColorPicker` expects `"#rrggbb"` or `"#rrggbbaa"` string. `RgbColorPicker` expects `{ r: number, g: number, b: number }` object. Check the 'Supported Color Models' section in the documentation for each picker's specific input/output format.