Colour picker
A swatch that opens a colour square and a row of preset colours.
A swatch that opens a colour square and a row of preset colours.
npm install @heroui/react
First time with HeroUI? Set it up once.
/**
* Demo from HeroUI, https://heroui.com (docs example color-picker/basic.tsx).
* Apache-2.0, Copyright 2025 NextUI Inc. Full text: https://github.com/heroui-inc/heroui/blob/main/LICENSE
* Changed for Tastebud: a default export (HeroUI's docs use named ones); a row of Figma palette swatches
* (from HeroUI's with-swatches example) in place of the rainbow hue slider.
*/
import {ColorArea, ColorPicker, ColorSwatch, ColorSwatchPicker, Label} from "@heroui/react";
const presets = ["#1ABCFE", "#A259FF", "#0ACF83", "#F24E1E", "#FFC700", "#FF7262", "#1E1E1E"];
export default function ColorPickerDemo() {
return (
<ColorPicker defaultValue="#1ABCFE">
<ColorPicker.Trigger>
<ColorSwatch size="lg" />
<Label>Pick a color</Label>
</ColorPicker.Trigger>
<ColorPicker.Popover>
<ColorArea
aria-label="Color area"
className="max-w-full"
colorSpace="hsb"
xChannel="saturation"
yChannel="brightness"
>
<ColorArea.Thumb />
</ColorArea>
<ColorSwatchPicker aria-label="Preset colors" className="justify-center px-1" size="xs">
{presets.map((preset) => (
<ColorSwatchPicker.Item key={preset} color={preset}>
<ColorSwatchPicker.Swatch />
</ColorSwatchPicker.Item>
))}
</ColorSwatchPicker>
</ColorPicker.Popover>
</ColorPicker>
);
}
Changed for this site: A default export (HeroUI's docs use named ones); a row of Figma palette swatches (from HeroUI's with-swatches example) in place of the rainbow hue slider.