Components
HeroUI v3 ColorArea is a 2D color picker surface for adjusting two channels of a color at once (e.g. saturation/brightness) via a draggable thumb. Built on the real @heroui/react package with @heroui/styles, it supports controlled and uncontrolled value, disabled state, selectable color space & channels, a dotted-grid variant, and a custom render function. A thin re-export of the upstream component so consumers install and render the genuine HeroUI primitive.
npx shadcn@latest add https://21st.dev/r/hero_ui/heroui-color-areaLoading preview...
"use client"
import type {Color} from "@heroui/react";
import { ColorSwatch, parseColor } from "@heroui/react"
import { ColorArea } from "@/components/ui/heroui-color-area"
import {useState} from "react";
export function ColorAreaControlled() {
const [color, setColor] = useState<Color>(parseColor("#9B80FF"));
return (
<div className="flex flex-col gap-4">
<ColorArea colorSpace="rgb" value={color} xChannel="red" yChannel="green" onChange={setColor}>
<ColorArea.Thumb />
</ColorArea>
<div className="flex w-[300px] items-center gap-3">
<ColorSwatch color={color} size="md" />
<p className="text-sm text-muted">
Current color:{" "}
<span className="font-medium">{color ? color.toString("hex") : "(empty)"}</span>
</p>
</div>
</div>
);
}
export default ColorAreaControlled
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...