Colors

Color Slider

Adjust a single channel of a color.

Rust
1use herogpui::components::color_picker::{ColorChannel, ColorSlider};

Usage

Rust
1use herogpui::prelude::{ColorChannel, ColorSlider};
2
3ColorSlider::new(
4    "color-slider",
5    value,
6    ColorChannel::Hue,
7)
8.default_value(value)

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

Anatomy

Rust types

ColorSlider

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

Customization

Appearance builders and theme tokens Color Slider uses.

Styling

Color Slider styling
StyleDescription
flex_col + gap(4)The four-pixel label/output-to-track gap matches; uses flex rows instead of CSS grid areas.
14px/20px MEDIUM label/output rowPlacement, 14px size, explicit 20px line height, medium weight, and disabled label/output opacity split match; GPUI has no tabular-number switch.
track_h=20 + COLOR_SLIDER_TRACK_INSET_PXCross-axis thickness, rounded total footprint, endpoint inset, and pointer travel match; the Rust gradient continues through the rounded caps rather than drawing separate solid endpoint fills.
theme borderA theme border substitutes for the inset edge shadows.
16px + rounded(16) + border(3)Size, circular radius, border, current-color fill, and disabled default fill match; overlay shadow is absent.
ColorSliderThumbStateDragging state is exposed, but GPUI provides one pointer cursor for the track rather than a separate grabbing cursor.

API reference

Builders

Color Slider builders
BuilderTypeDefaultDescription
new(id, value, channel)id, value, channelRequired channel supplied positionally and edited with its pinned range and step.
color_space(ColorSpace)ColorSpaceColorSpace::ValueColorSpaceSelects HSB, HSL, or RGB interpretation; invalid channel/space pairs are accepted rather than auto-corrected with a warning.
new(id, PickerColor, channel)id, PickerColor, channelControlled color waits for owner acceptance after pointer and keyboard reports.
default_value(PickerColor)PickerColorSeeds picker-owned color state once.
on_change(callback)Fn(value: Color) -> ()Reports each changed pointer coordinate or keyboard step.
on_change_end(callback)Fn(value: Color) -> ()Reports once on release and once for each completed keyboard change.
orientation(Orientation)OrientationOrientation::HorizontalSwitches the value axis and vertical layout direction.
is_disabled(bool)boolfalseRemoves focus, pointer, keyboard, and successful form submission while masking thumb interaction state.
name(text) + form_field()text) + form_field(Registers the live channel number for FormData.
show_label / output / thumbAnyElement | render closureThe monolithic Rust root composes built-in label, output, track, and thumb parts; root replacement is unavailable.
length(Pixels)PixelsBrowser class customization and root-element substitution are unavailable; length provides geometry customization.
output(render)AnyElement | render closureformatted valueReplacement output receives current color and formatted channel text.
built-in trackAnyElement | render closureColorSlider.ThumbThe built-in track owns the thumb; independent track render content and hover state are unavailable.
thumb(render)AnyElement | render closureCaller content receives color, dragging, hovered, focused, focus-visible, and disabled state.

Parts

Color Slider parts
PartDescription
ColorSliderValue, orientation, form, label/output layout, and interaction owner.
ColorSliderBuilt-in channel name; arbitrary label composition is unavailable.
ColorSliderFormatted value or caller-rendered color/value content.
ColorSliderGradient and pointer geometry owner; independent child render state is unavailable.
ColorSliderCurrent-color indicator, focus ring, and complete shared ColorThumb render state.

States

Color Slider states
BuilderStateDescription
is_disabledDisabledTrack dims, thumb uses default fill, interaction is removed, FormData is omitted, and thumb state is masked.
dragging keyed state + ColorSliderThumbStateDraggingSame-value and changed-value presses expose live dragging state until global release.
thumb_hovered keyed stateHoveredEnabled thumb hover reaches its render function.
focus_handle + ColorSliderThumbStateFocusedPointer and keyboard focus reach thumb render state.
with_focus_ring(thumb) + focus_visibleFocus visibleKeyboard-origin focus rings the thumb rather than the whole track.