pub trait Buttons: ThemeExt {
// Provided methods
fn button(
&self,
label: impl Into<SharedString>,
style: ButtonStyle,
fade: Option<Fade>,
) -> Div { ... }
fn icon_button(
&self,
icon: impl Into<Icon>,
style: ButtonStyle,
fade: Option<Fade>,
) -> Div { ... }
fn control_group(&self) -> Div { ... }
fn ghost(&self, id: impl Into<ElementId>) -> Stateful<Div> { ... }
}Provided Methods§
A labeled button in one of the shipped styles. fade matters only for
ButtonStyle::Ghost: Some animates the hover wash per instance,
None is the plain ghost with the hover left to the caller.
A button that is only a glyph — SwiftUI’s toolbar Button over an icon
Label. Square at Theme::BUTTON_HEIGHT, so it stands the same
height as a Self::button beside it. fade reads as it does there.
It builds the glyph rather than taking one: gpui reads an svg’s colour off that element’s own style and paints nothing when it is unset, so a colour set on this button would silently not reach it.
An icon carries no accessible name — reach for
crate::tooltip on the way past.
Sourcefn control_group(&self) -> Div
fn control_group(&self) -> Div
SwiftUI’s ControlGroup, and what a toolbar paints behind the items it
finds side by side: one shared background, its buttons inset in it. A
second cluster is a second call — the break between them is the spacing,
the way ToolbarSpacer puts it there.
The track’s radius is the item’s plus the inset, so an ordinary
Self::button or Self::icon_button drops in already concentric.
Items are left to stretch: that is what holds a glyph and a label to one
height when the type ladder moves under them. self_start because the
group must hug them — dropped into a flex_col, flexbox’s default
align-items: stretch would otherwise blow it out to the column’s full
width.
Glass is chained, not baked: .surface(theme, theme.popover_surface)
turns the track into the capsule a macOS 26 toolbar floats.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".