React beautiful color
react color picker you can actually customize
The most flexible and beautiful color picker for React. Built with compound components for maximum customization. The project is written primarily in TypeScript, distributed under the MIT License license, first published in 2025. Key topics include: alpha, color, color-picker, compound-components, hue.
react-beautiful-color
The most flexible and beautiful color picker for React. Built with compound components for maximum customization.
Why Choose This Over Others?
- ๐งฉ Compound Components - Compose your own layout, unlike rigid alternatives
- ๐จ Beautiful Design - Clean, modern UI that fits any design system
- โก Smart Hook -
useColorStatepreserves your input format while providing all color formats instantly - ๐ก๏ธ Type-Safe API - Full TypeScript support with comprehensive type definitions
- ๐๏ธ Eye Dropper Support - Built-in screen color picker (where browser supports it)
- ๐ฏ Format Preservation - Maintains your original color format throughout interactions
- ๐ Universal Format Support - Hex, RGB/RGBA, HSL/HSLA, HSV/HSVA with alpha channel
- ๐ชถ Lightweight - Pure Tailwind CSS, no external dependencies
- ๐ ๏ธ Fully Customizable - Style and arrange components however you want
- ๐ง Rich Utilities - Comprehensive color conversion and manipulation utilities
Installation
bashbun add react-beautiful-color
๐ View Full Documentation โ
Quick Start
1. Add CSS to your layout file:
tsx// app/layout.tsx (Next.js) or pages/_app.tsx or index.tsx import 'react-beautiful-color/dist/react-beautiful-color.css';
2. Use the component:
tsximport { ColorPicker, useColorState } from 'react-beautiful-color'; import { Pipette } from 'lucide-react'; function App() { const [{ colorInput, colorState }, setColor] = useColorState({ type: 'hex', value: '#3b82f6' }); return ( <ColorPicker color={colorInput} onChange={setColor}> <ColorPicker.Saturation className="flex-1 mb-3" /> <div className="flex items-center gap-3 p-3 pt-0"> <ColorPicker.EyeDropper> <Pipette /> </ColorPicker.EyeDropper> <div className="flex-1 flex flex-col gap-3"> <ColorPicker.Hue className="h-4" /> <ColorPicker.Alpha className="h-4" /> </div> </div> </ColorPicker> ); }
Components
๐จ ColorPicker
Compose your own layout with these sub-components:
ColorPicker.Saturation- Saturation and brightness selection areaColorPicker.Hue- Hue selection sliderColorPicker.Alpha- Alpha/transparency sliderColorPicker.EyeDropper- Eye dropper tool (browser-dependent)
๐ Learn more about ColorPicker โ
โก useColorState Hook
Intelligent state management with format preservation:
tsxconst [{ colorInput, colorState }, setColor] = useColorState({ type: 'hsva', h: 334, s: 100, v: 100, a: 0.5 }); // colorInput preserves your format - always HSVA! console.log(colorInput); // { type: 'hsva', h: 334, s: 100, v: 100, a: 0.5 } // colorState provides ALL formats instantly console.log(colorState.hex); // "#ff6b9d" console.log(colorState.rgb); // { r: 255, g: 107, b: 157 } console.log(colorState.hsl); // { h: 334, s: 100, l: 71 } console.log(colorState.alpha); // 0.5
๐ Learn more about useColorState โ
Utilities
Powerful color conversion and manipulation utilities:
tsximport { hexToRgb, rgbToHex, hexToHsl, hslToHex } from 'react-beautiful-color'; // Color conversions const rgb = hexToRgb('#ff6b9d'); // { r: 255, g: 107, b: 157 } const hex = rgbToHex(255, 107, 157); // "#ff6b9d" const hsl = hexToHsl('#ff6b9d'); // { h: 334, s: 100, l: 71 }
๐ View all utility functions โ
Advanced Usage
Multiple Format Support
Set colors in any format with complete type safety:
tsxsetColor({ type: 'hex', value: '#ff0000' }); setColor({ type: 'rgb', r: 255, g: 0, b: 0 }); setColor({ type: 'hsl', h: 0, s: 100, l: 50 }); setColor({ type: 'rgba', r: 255, g: 0, b: 0, a: 0.5 }); setColor({ type: 'hsla', h: 0, s: 100, l: 50, a: 0.8 }); setColor({ type: 'hsva', h: 0, s: 100, v: 100, a: 0.9 });
Alternative without Hook
Use the Color class directly for more control:
tsximport { useState } from 'react'; import { ColorPicker, Color } from 'react-beautiful-color'; function App() { const [color, setColor] = useState(new Color({ type: 'hex', value: '#3b82f6' })); // Access color properties const rgba = color.getRgba(); const hex = color.getHex(); const hsl = color.getHsl(); return ( <ColorPicker color={color} onChange={setColor}> <ColorPicker.Saturation className="flex-1 mb-3" /> <div className="flex items-center gap-3 p-3 pt-0"> <ColorPicker.EyeDropper /> <div className="flex-1 flex flex-col gap-3"> <ColorPicker.Hue className="h-4" /> <ColorPicker.Alpha className="h-4" /> </div> </div> </ColorPicker> ); }
Documentation
๐ View Full Documentation โ
- Getting Started - Installation and basic setup
- ColorPicker Component - Main component API
- useColorState Hook - Intelligent state management
- Individual Components - Saturation, Hue, Alpha components
- Utility Functions - Color conversion utilities
Support
<a href="https://www.buymeacoffee.com/ozergklp" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
Contributors
Showing top 4 contributors by commit count.

