npm install cromia Examples
Area, sliders, input, and swatches.
Individual H·S·B·A editable sliders.
Just the essentials — area and hue.
Preset palette with hue fine-tuning.
Usage
Install
Add cromia to your project. Works with any React 18+ or 19+ setup.
npm install cromiaBasic picker
Compose a minimal picker with an area selector, hue slider, and hex input.
import { ColorPicker } from 'cromia';
import { useState } from 'react';
function Picker() {
const [color, setColor] = useState('#3B82F6');
return (
<ColorPicker.Root color={color} onColorChange={setColor}>
<ColorPicker.Area className="relative h-48 w-full">
<ColorPicker.AreaBackground />
<ColorPicker.AreaThumb />
</ColorPicker.Area>
<ColorPicker.ChannelSlider channel="hue">
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
<ColorPicker.Input channel="hex" />
</ColorPicker.Root>
);
}Color swatches
Add preset color swatches so users can quickly pick from a curated palette.
const swatches = ['#E44444', '#3B82F6', '#22C55E'];
<ColorPicker.Root color={color} onColorChange={setColor}>
<ColorPicker.SwatchGroup>
{swatches.map((c) => (
<ColorPicker.Swatch
key={c}
value={c}
selected={color === c}
onSelect={setColor}
/>
))}
</ColorPicker.SwatchGroup>
</ColorPicker.Root>Channel sliders
Expose individual hue, saturation, brightness, and alpha channels as editable sliders.
const channels = ['hue', 'saturation', 'brightness', 'alpha'];
<ColorPicker.Root color={color} onColorChange={setColor}>
{channels.map((ch) => (
<div key={ch}>
<ColorPicker.Input channel={ch} />
<ColorPicker.ChannelSlider channel={ch}>
<ColorPicker.ChannelSliderTrack />
<ColorPicker.ChannelSliderThumb />
</ColorPicker.ChannelSlider>
</div>
))}
</ColorPicker.Root>