Appica UIUI 1.1.0

Color Area

A two-dimensional gradient for adjusting two channels of a color at once.

Usage

ColorArea paints a plane of a color space and puts a draggable thumb on it. The horizontal axis drives xChannel, the vertical axis drives yChannel (increasing upwards), and the third channel of the space is held constant - it's what the plane is a slice of. Pair it with a slider for that third channel and you have a color picker.

The value is a Color: a plain object you get from parseColor, or any CSS color string passed straight to value / defaultValue. Because it's a plain object and not a class instance, it serializes cleanly across the server/client boundary. Every handler is called with a Color, which you format with formatColor.

The color space comes from the value, so parseColor('hsl(…)') gives an HSL area and a hex string gives an RGB one. Set colorSpace to override it and convert on the way in.

A space and a format are different things, and it's worth being clear about which is which. The space is the set of axes you move along (rgb, hsl, hsb); the format is how the result gets written down. Hex is a format, not a space - #3b82f6 and rgb(59, 130, 246) are the same color in the same space, spelled differently. Pick in whichever space suits the control, then call formatColor for whatever you need to store.

Give the area a name with aria-label: it has no visible text, and the name is what a screen reader reads before the channel values.

Inside a Color Picker the value and the handlers can be left off entirely: the area reads and writes the picker's color through context.

Examples

Color spaces

Three spaces can be plotted: rgb, hsl, and hsb. Each is separable, so the browser paints the plane from two stacked CSS gradients over a solid base - no per-pixel work, and it renders during SSR. Below is the same blue, sliced along a different pair of channels in each.

Building a picker

ColorArea covers two channels, so the third needs its own control: a Color Slider. Add a second one for alpha and a Color Swatch for the result, and you have the shape most pickers take. Every part reads and writes the same Color, so composing them is just sharing one piece of state.

Output formats

The area works in one space and hands you a Color; formatColor writes that out in any format you like, with no second control needed. Here the same pick is shown four ways at once - drag the thumb and every line updates.

Choosing channels

Any two channels of the space can go on the axes. Here red runs horizontally and blue vertically, leaving green as the constant - move the thumb and only two of the three readouts change.

Sizing

The area is size-56 (224px) by default and takes any size through className. The corner radius carries to the gradient and the ring, so a fully rounded area works too. thumbProps reaches the thumb, for a smaller one on a small area.

Forms

xName and yName name the two hidden range inputs the component already renders for accessibility, so the axis values submit with a plain HTML form. No hidden field or onSubmit plumbing needed.

Disabled

disabled blocks interaction and swaps the gradient for a flat muted fill inside a dashed outline, dimmed.

RTL

Every Appica UI component supports right-to-left layouts out of the box. Set the dir attribute on a container (commonly your <html> element) so CSS logical properties resolve correctly, and wrap your tree in DirectionProvider so direction-aware behavior (roving focus, popup placement, and the like) follows the same direction.

The horizontal axis mirrors: the x channel's minimum sits on the right edge, the gradient flows the same way, and ←/→ swap so the arrow that moves the thumb toward the maximum is still the one pointing at it. The vertical axis is unaffected. For setup details and caveats, see the RTL guide.

لون العلامة التجارية

API reference

ColorArea

Every other <div> attribute is forwarded to the root. The root carries data-space, data-disabled and data-dragging; the parts are addressable through data-slot (color-area, color-area-surface, color-area-thumb).

Color utilities

The color model ships from its own subpath, @appica/ui-react/color, and is shared by every color component.

Accessibility

  • The root is a role="group" holding two visually hidden <input type="range">, one per axis, so assistive technology gets a real value, bounds, and step for each channel. Only the focused axis is in the tab order.
  • aria-valuetext on both inputs spells out all three channels of the space, so the constant channel is announced too. aria-roledescription marks the control as a two-dimensional slider.
  • Keyboard: ←/→ move the x channel and ↑/↓ the y channel by one step, Shift with an arrow moves by the page step, Page Up·Down move the y channel by the page step, and Home/End move the x channel by the page step.
  • The thumb is a white rim with a faint dark ring on each side of it, so it keeps an edge over any point of the plane in either theme - including when the picked color is itself white. forced-color-adjust: none keeps the gradient intact in forced-colors mode.
  • The thumb's position is never transitioned, so it sits exactly under the pointer. The only animation is the scale while it is pressed, and that honors prefers-reduced-motion.

© 2026 Appica UI. A free component library, crafted by the Appica team.