ProComponents, templates & AI tooling
HeroUI
27.7k

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.

PropTypeDefaultDescription
valuestring | Color-The current color value (controlled)
defaultValuestring | 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
xChannelColorChannel"saturation"Color channel for the horizontal axis
yChannelColorChannel"brightness"Color channel for the vertical axis
colorSpaceColorSpace-The color space for the channels
isDisabledbooleanfalseWhether the color area is disabled
showDotsbooleanfalseWhether to show the dot grid overlay
classNamestring-Additional CSS classes
renderDOMRenderFunction<keyof React.JSX.IntrinsicElements, ColorAreaRenderProps>-Overrides the default DOM element with a custom render function.

ColorArea.Thumb

PropTypeDefaultDescription
classNamestring-Additional CSS classes
styleCSSProperties | ((renderProps) => CSSProperties)-Inline styles or render props function
renderDOMRenderFunction<keyof React.JSX.IntrinsicElements, ColorThumbRenderProps>-Overrides the default DOM element with a custom render function.

On this page