pub struct ColorPicker<'a> { /* private fields */ }Expand description
A click-to-open color picker bound to a Color32.
The widget paints a compact swatch-and-hex trigger; the picker UI lives
in a Popover. Configure which sub-controls the
popover shows via the builder. By default the popover contains a
continuous picker (saturation/value plane plus hue slider), an alpha
slider, and a hex input.
Implementations§
Source§impl<'a> ColorPicker<'a>
impl<'a> ColorPicker<'a>
Sourcepub fn new(id_salt: impl Hash, color: &'a mut Color32) -> Self
pub fn new(id_salt: impl Hash, color: &'a mut Color32) -> Self
Create a color picker keyed by id_salt and bound to color.
Defaults: continuous picker on, alpha slider on, hex input on,
recents tracked, opens below the trigger.
Sourcepub fn label(self, label: impl Into<WidgetText>) -> Self
pub fn label(self, label: impl Into<WidgetText>) -> Self
Show a label above the trigger.
Sourcepub fn palette(self, palette: impl IntoIterator<Item = Color32>) -> Self
pub fn palette(self, palette: impl IntoIterator<Item = Color32>) -> Self
Supply a curated palette grid above the recents row. When unset
(the default) no palette is shown. Use ColorPicker::default_palette
for a 30-swatch starter palette inspired by Tailwind.
Sourcepub fn palette_columns(self, n: usize) -> Self
pub fn palette_columns(self, n: usize) -> Self
Number of columns in the palette grid. Default: 10.
Sourcepub fn continuous(self, on: bool) -> Self
pub fn continuous(self, on: bool) -> Self
Toggle the continuous saturation/value plane and hue slider. Default: on.
Sourcepub fn alpha(self, on: bool) -> Self
pub fn alpha(self, on: bool) -> Self
Toggle the alpha slider. Default: on. Disable for opaque-only colors.
Sourcepub fn hex_input(self, on: bool) -> Self
pub fn hex_input(self, on: bool) -> Self
Toggle the hex input row inside the popover. Default: on.
Sourcepub fn hex_label(self, on: bool) -> Self
pub fn hex_label(self, on: bool) -> Self
Show or hide the hex string next to the swatch on the trigger button. Default: shown.
Sourcepub fn recents(self, on: bool) -> Self
pub fn recents(self, on: bool) -> Self
Toggle the recents row. The recent picks are persisted in egui
context memory keyed by the picker’s id_salt. Default: on.
Sourcepub fn recents_max(self, n: usize) -> Self
pub fn recents_max(self, n: usize) -> Self
Maximum number of recent picks remembered. Default: 10.
Sourcepub fn side(self, side: PopoverSide) -> Self
pub fn side(self, side: PopoverSide) -> Self
Which side of the trigger the popover opens on. Default: below.
Sourcepub fn default_palette() -> Vec<Color32>
pub fn default_palette() -> Vec<Color32>
A 30-swatch curated palette: a row of neutrals, a row of cool
accents, and a row of warm accents. Pass to ColorPicker::palette.