pub struct SegmentedButton<'a> { /* private fields */ }Expand description
A toggle button with a built-in LED dot.
SegmentedButton shares ButtonSize with Button, so a
mixed action row stays aligned when both widgets pass matching
.size(...) values.
let mut on = false;
// Default: ButtonSize::Medium — aligns with Medium Button.
ui.add(SegmentedButton::new(&mut on, "Continuous").accent(Accent::Green));
// Chunkier row — Button + SegmentedButton, same height.
ui.horizontal(|ui| {
ui.add(Button::new("Collect").size(ButtonSize::Large));
ui.add(
SegmentedButton::new(&mut on, "Continuous")
.accent(Accent::Green)
.size(ButtonSize::Large),
);
});Implementations§
Source§impl<'a> SegmentedButton<'a>
impl<'a> SegmentedButton<'a>
Sourcepub fn new(on: &'a mut bool, label: impl Into<WidgetText>) -> Self
pub fn new(on: &'a mut bool, label: impl Into<WidgetText>) -> Self
Create a segmented button bound to on with the given label.
Sourcepub fn accent(self, accent: Accent) -> Self
pub fn accent(self, accent: Accent) -> Self
Pick the on-state colour from one of the theme’s accents. Default: Accent::Green.
Sourcepub fn size(self, size: ButtonSize) -> Self
pub fn size(self, size: ButtonSize) -> Self
Pick a size preset matching Button’s sizes so a
mixed Button + SegmentedButton row stays aligned at any size.
Default: ButtonSize::Medium.
Sourcepub fn dim_when_on(self, dim: bool) -> Self
pub fn dim_when_on(self, dim: bool) -> Self
When the button is on, render its fill dimmed and the label muted. Used to indicate “enabled but not currently applicable”.
Sourcepub fn rounded(self, rounded: bool) -> Self
pub fn rounded(self, rounded: bool) -> Self
Set whether the button has rounded corners. Disable for segmented groups where neighbours share edges.
Sourcepub fn corner_radius(self, radius: impl Into<CornerRadius>) -> Self
pub fn corner_radius(self, radius: impl Into<CornerRadius>) -> Self
Explicitly set the corner radius (per-corner). Overrides Self::rounded.
Useful for segmented strips where only the end cells should be rounded.