A wrapper around react-color
configured for custom themes and design systems. Built with TypeScript, Tailwind CSS, and shadcn/ui.
Unlike traditional color pickers, this component focuses on design system consistency by limiting color selection to 5 variants of each chosen color. This approach ensures color harmony while maintaining flexibility in your design choices.
git clone https://github.com/leomiranda/react-color-picker.git
npm install
# or
yarn
# or
pnpm install
npm run dev
# or
yarn dev
# or
pnpm dev
A compact color picker that opens in a popover when clicked. Perfect for inline color selection.
import { PopoverColorPicker } from './components/PopoverColorPicker';
<PopoverColorPicker
color="#000000"
paletteColors={['#068d9d', '#53599a']}
suggestedColor="#6d9dc5"
onColorChange={(color) => console.log(color)}
triggerClassName="w-10 h-10"
/>;
Prop | Type | Default | Description |
---|---|---|---|
color | string | required | The current color value |
paletteColors | string[] | required | Array of colors to display in the palette |
suggestedColor | string | undefined | Optional suggested color to display |
onColorChange | (color: string) => void | required | Callback when color changes |
triggerClassName | string | 'w-9 h-9' | Custom classes for the trigger button |
A full-sized color picker displayed in a card format. Ideal for dedicated color selection interfaces.
import { CardColorPicker } from './components/CardColorPicker';
<CardColorPicker
color="#000000"
paletteColors={['#068d9d', '#53599a']}
suggestedColor="#6d9dc5"
onColorChange={(color) => console.log(color)}
/>;
Prop | Type | Default | Description |
---|---|---|---|
color | string | required | The current color value |
paletteColors | string[] | required | Array of colors to display in the palette |
suggestedColor | string | undefined | Optional suggested color to display |
onColorChange | (color: string) => void | required | Callback when color changes |
When you select a color, the system automatically generates 5 variants that work harmoniously together:
const palette = [
{
title: 'Primary',
slug: 'primary',
value: '#068d9d',
},
{
title: 'Secondary',
slug: 'secondary',
value: '#53599a',
},
{
title: 'Tertiary',
slug: 'tertiary',
value: '#6d9dc5',
},
{
title: 'Quaternary',
slug: 'quaternary',
value: '#80ded9',
},
{
title: 'Quintenary',
slug: 'quintenary',
value: '#aeecef',
},
];
function App() {
const [color, setColor] = useState('#000000');
const paletteColors = palette.map((p) => p.value);
const suggestedColor = palette.find((p) => p.slug === 'secondary')?.value;
return (
<PopoverColorPicker
color={color}
paletteColors={paletteColors}
suggestedColor={suggestedColor}
onColorChange={setColor}
/>
);
}
This approach ensures:
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.