pub fn button() -> ButtonBuilderExpand description
§button
Provides a clickable button with customizable style and ripple feedback.
§Usage
Use to trigger an action when the user clicks or taps.
§Parameters
variant— optional visual variant (filled/elevated/tonal/outlined/text).size— Expressive size preset; defaults to small.shape_style— round or square preset; defaults to round.selected— controlled toggle state; omit for an ordinary action. Text buttons do not support toggling. Update this value inon_click.interaction_state— optional shared state tracking live pointer and focus interactions.presentation_ripple— optional static circular ripple for pressed visual presentation.presentation_state— optional visual interaction without changing input or focus.enabled— optional enabled flag.modifier— modifier chain applied to the button subtree.color— optional container color override.content_color— optional content color override.shape— fixed shape override, replacing automatic corner morphing.padding— optional uniform internal padding override.content_padding— optional per-edge insets; takes precedence overpadding.leading_icon,trailing_icon— optional icons, sized and spaced by the preset.on_click— optional click callback.ripple_color— optional ripple tint override.border_width— optional outline width.border_color— optional outline color.elevation— optional surface elevation.tonal_elevation— optional tonal elevation.disabled_container_color— optional disabled container color.disabled_content_color— optional disabled content color.disabled_border_color— optional disabled border color.accessibility_label— optional accessibility label.accessibility_description— optional accessibility description.accessibility_role— optional semantic role; defaults to button.child— optional child render slot.
§Examples
use tessera_components::{button::button, text::text};
let selected = tessera_ui::remember(|| false);
let toggle = tessera_ui::Callback::new(move || selected.set(!selected.get()));
button()
.tonal()
.square()
.selected(selected.get())
.on_click_shared(toggle)
.child(|| {
text("Favorite");
});
assert!(!selected.get());
toggle.call();
assert!(selected.get());Renders a Material button.