Colors

Color Area

Pick saturation and lightness from a two-dimensional gradient.

Rust
1use herogpui::components::color_picker::ColorArea;

Usage

Rust
1use herogpui::prelude::ColorArea;
2
3ColorArea::new("color-area", value)
4    .default_value(value)

Live HeroGPUI compiled to WebAssembly. Select any example without loading another WASM instance.

Anatomy

Rust types

ColorArea

Color Area is assembled from these builders. The API reference lists each one.

Customization

Appearance builders and theme tokens Color Area uses.

Styling

Color Area styling
StyleDescription
224x224 + size(width, height) + soft_radiusThe default desktop area is the 224px square with 16px corners; size can override both axes.
border(theme border)Uses a theme border rather than the translucent inner shadow.
show_dots 8px gridTwo-pixel translucent dots are centered in an eight-pixel grid because GPUI has no repeating radial background.
16px + rounded(12) + border(3)Idle size, circular radius, white border, and current-color fill match.
color_area_thumb_motionA listener-free visual child interpolates the current size, preserves reversal position, and switches directly under reduced motion.
COLOR_AREA_THUMB_DRAGGING_PXActive drag size is 20px while the stable owner keeps hover continuity.
with_focus_ring(thumb)The shared status ring is applied to the animated thumb visual.

API reference

Builders

Color Area builders
BuilderTypeDefaultDescription
new(id, PickerColor)id, PickerColorControlled color; pointer and keyboard changes wait for owner acceptance.
default_value(PickerColor)PickerColorSeeds picker-owned color state once.
on_change(callback)Fn(color: Color) -> ()Reports each changed pointer coordinate or keyboard step.
on_change_end(callback)Fn(color: Color) -> ()Reports once on pointer release and once for each completed keyboard change.
x_channel(ColorChannel)ColorChannelColorChannel::SaturationSelects the horizontal channel and its pinned step/range.
y_channel(ColorChannel)ColorChannelColorChannel::BrightnessSelects the vertical channel, increasing toward the top.
color_space(ColorSpace)ColorSpaceSelects HSB, HSL, or RGB channel interpretation and default axes.
is_disabled(bool)boolfalseDims the complete area and removes focus, pointer, and keyboard interaction.
show_dots(bool)boolfalseOverlays the eight-pixel precision grid.
thumb(render)AnyElement | render closureColorArea.ThumbThe monolithic area always owns the thumb; its child render state is exposed through the thumb builder.
size(width, height)width, heightBrowser classes and root-element substitution are unavailable; size provides the desktop geometry customization point.

Parts

Color Area parts
PartDescription
ColorAreaTwo-dimensional gradient, value owner, focus target, and pointer/keyboard interaction surface.
ColorAreaPositioned current-color indicator with live render state and drag geometry.

States

Color Area states
BuilderStateDescription
is_disabledDisabledWhole-control opacity applies and every interaction/render-state flag is masked except disabled.
dragging keyed state + ColorAreaThumbStateDraggingPointer down grows the thumb from 16px to 20px and reaches the thumb render state even when the color is unchanged.
thumb_hovered keyed stateHoveredThe stable thumb owner reports hover without placing listeners above a changing animation id.
ColorAreaThumbStateFocusedPointer and keyboard focus are reported from the area focus handle.
with_focus_ring(thumb) + focus_visibleFocus visibleKeyboard-origin focus rings the thumb, not the whole gradient, and reaches render state.