pub trait ButtonBuilder: Sized {
// Required methods
fn icon<M>(self, symbol: impl IntoReactive<Symbol, M>) -> Self;
fn image(self, name: impl Into<ImageName>) -> Self;
fn icon_only(self) -> Self;
fn action(self, f: impl Fn() + 'static) -> Self;
fn bordered(self) -> Self;
fn enabled<M>(self, v: impl IntoReactive<bool, M>) -> Self;
fn prominent(self) -> Self;
fn tint<M>(self, color: impl IntoReactive<Color, M>) -> Self;
fn compact(self) -> Self;
fn plain(self) -> Self;
fn selected<M>(self, v: impl IntoReactive<bool, M>) -> Self;
}Expand description
Required Methods§
Sourcefn icon<M>(self, symbol: impl IntoReactive<Symbol, M>) -> Self
fn icon<M>(self, symbol: impl IntoReactive<Symbol, M>) -> Self
Show a platform symbol. A signal or closure updates it without replacing the button.
Sourcefn image(self, name: impl Into<ImageName>) -> Self
fn image(self, name: impl Into<ImageName>) -> Self
Show a bundled image or vector alongside the label.
Sourcefn icon_only(self) -> Self
fn icon_only(self) -> Self
Hide the visible label when an icon is available; retain it for accessibility and help.
Sourcefn action(self, f: impl Fn() + 'static) -> Self
fn action(self, f: impl Fn() + 'static) -> Self
Handle native button activation by pointer, keyboard, or accessibility action. Disabled buttons do not invoke this callback.
Use this instead of Decorate::on_tap. A tap decorator adds a separate gesture
recognizer that can delay pressed feedback and bypass native control behavior.
Day logs a warning when a tap gesture is attached to a native button.
Sourcefn bordered(self) -> Self
fn bordered(self) -> Self
Ask for a visually CONTAINED native button on toolkits whose stock look is borderless (iOS’s plain system button reads as a link); a no-op where buttons are already bordered.
Sourcefn enabled<M>(self, v: impl IntoReactive<bool, M>) -> Self
fn enabled<M>(self, v: impl IntoReactive<bool, M>) -> Self
Whether the button is interactive (default true; false = disabled/grayed by the native
control). Reactive, so it can follow app state, e.g. .enabled(move || !busy.get()) to
lock a control while a long operation runs.
This drives the platform’s own disabled rendering through ButtonPatch::Enabled; it is not
a painted imitation, and a disabled button stops delivering Event::Pressed at the source.
Sourcefn prominent(self) -> Self
fn prominent(self) -> Self
The platform’s accent-filled / default-action button (iOS bordered-prominent, macOS return-key blue, GTK suggested-action, XAML accent style). Use for the one primary action of a view.
Sourcefn tint<M>(self, color: impl IntoReactive<Color, M>) -> Self
fn tint<M>(self, color: impl IntoReactive<Color, M>) -> Self
A filled button in a color of your choosing, still drawn by the native control.
The platform keeps everything that makes a button a button: its pressed and hover rendering, its focus ring, its disabled look, its accessibility role, and keyboard activation. Only the fill is yours. The label color is chosen for contrast against the fill, so a pale tint gets dark text and a saturated one white.
Reactive, so the color can follow app state: .tint(move || if recording { RUST } else { SKY }) recolors in place rather than rebuilding the button.
A backend that cannot recolor its button ignores the tint and draws its ordinary button (docs/buttons.md), because a plain button on one platform is a far smaller loss than a colored rectangle that is no longer a button.
Sourcefn compact(self) -> Self
fn compact(self) -> Self
A button no wider than its title: a stepper’s “−” and “+”, a chip’s “×”. Drops the minimum width and wide insets of toolkits that have them (Material); a no-op where the stock button already hugs its title.
Sourcefn plain(self) -> Self
fn plain(self) -> Self
Borderless native action button for toolbars and list-row accessories. Preserves native interaction, focus, disabled rendering, and accessibility.
Sourcefn selected<M>(self, v: impl IntoReactive<bool, M>) -> Self
fn selected<M>(self, v: impl IntoReactive<bool, M>) -> Self
Mark this button as the current choice among its peers: a document tab, one view of a
switcher. The platform draws its own checked or selected look (an NSButton’s on state,
UIButton.isSelected, GTK’s :checked, a checked QPushButton, a checked
MaterialButton, aria-pressed on the web) and announces it as selected, while the
button stays enabled, focusable and activatable, which a disabled stand-in is not.
Reactive, so it follows the selection: .selected(move || current.get() == key). A press
never toggles the state natively; the app’s handler decides, and the next value of the
closure is what the control shows.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".