React Colorful Color Picker

5.6.1 · active · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

import React, { useState } from 'react';
import { HexColorPicker } from 'react-colorful';

const MyColorPickerComponent = () => {
  const [color, setColor] = useState('#aabbcc');

  return (
    <div>
      <p>Selected Color: {color}</p>
      <HexColorPicker color={color} onChange={setColor} />
      <button onClick={() => setColor('#ff0000')}>Set Red</button>
      <button onClick={() => setColor('#00ff00')}>Set Green</button>
      <button onClick={() => setColor('#0000ff')}>Set Blue</button>
    </div>
  );
};

export default MyColorPickerComponent;

view raw JSON →