ColorArea
A 2D color picker that allows users to select colors from a gradient area
Usage
import { ColorArea } from '@heroui/react';Anatomy
import { ColorArea } from '@heroui/react';
export default () => (
<ColorArea>
<ColorArea.Thumb />
</ColorArea>
);Examples
With Dots
Color Space & Channels
Use colorSpace to set the color space (RGB, HSL, HSB) and xChannel/yChannel props to customize which color channels are displayed on each axis.
Disabled
Controlled
Render Function
Customization
Tailwind CSS
Global CSS
To customize the ColorArea component classes, you can use the @layer components directive.
Learn more.
@layer components {
.color-area {
@apply rounded-3xl;
}
.color-area__thumb {
@apply size-5 border-4;
}
}Styling Reference
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
CSS Classes
The ColorArea component uses these CSS classes (View source styles):
Base Classes
.color-area- Base styles with gradient background and inner shadow.color-area--show-dots- Adds dot grid overlay for precision picking
Element Classes
.color-area__thumb- Draggable thumb indicator
Interactive States
The component supports both CSS pseudo-classes and data attributes for flexibility:
- Disabled:
[data-disabled="true"] - Focus:
[data-focus-visible="true"] - Dragging:
[data-dragging="true"](thumb only)
API Reference
ColorArea
Inherits from React Aria ColorArea.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | Color | - | The current color value (controlled) |
defaultValue | string | Color | - | The default color value (uncontrolled) |
onChange | (color: Color) => void | - | Handler called when the color changes while dragging |
onChangeEnd | (color: Color) => void | - | Handler called when the user stops dragging |
xChannel | ColorChannel | "saturation" | Color channel for the horizontal axis |
yChannel | ColorChannel | "brightness" | Color channel for the vertical axis |
colorSpace | ColorSpace | - | The color space for the channels |
isDisabled | boolean | false | Whether the color area is disabled |
showDots | boolean | false | Whether to show the dot grid overlay |
className | string | - | Additional CSS classes |
render | DOMRenderFunction<keyof React.JSX.IntrinsicElements, ColorAreaRenderProps> | - | Overrides the default DOM element with a custom render function. |
ColorArea.Thumb
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
style | CSSProperties | ((renderProps) => CSSProperties) | - | Inline styles or render props function |
render | DOMRenderFunction<keyof React.JSX.IntrinsicElements, ColorThumbRenderProps> | - | Overrides the default DOM element with a custom render function. |





