Skip to main content

icon_button

Function icon_button 

Source
pub fn icon_button() -> IconButtonBuilder
Expand description

§icon_button

Display a compact action or controlled toggle with Expressive sizes and shapes.

§Usage

Offer named icon actions and persistent choices in toolbars and media controls.

§Parameters

  • variant — visual emphasis, defaulting to filled.
  • size / width — visual dimensions, defaulting to small and uniform.
  • shape_style — round or square resting corners; selection swaps the shapes.
  • selected — controlled toggle state; omit for an ordinary action.
  • icon — optional vector or raster icon, centered at the size’s icon dimensions.
  • on_click — activation callback; update selected here when using a toggle.
  • enabled — whether activation, focus, and interaction feedback are enabled.
  • modifier — outer constraints and node-local behavior.
  • shape — fixed shape override that disables automatic corner transitions.
  • color_style — vibrant or inherited colors for standard and outlined variants.
  • color / content_color — enabled container and icon color overrides.
  • interaction_state — optional shared pointer and focus state.
  • presentation_ripple — optional static circular ripple for pressed visual presentation.
  • presentation_state — optional visual interaction without changing input or focus.
  • accessibility_label / accessibility_description — action name and supporting help.

Interactive targets expand to at least 48dp when parent constraints permit. Disabled controls retain their target geometry and toggle state.

§Examples

use tessera_components::{
    icon_button::icon_button, material_icons::filled, theme::material_theme,
};
use tessera_ui::{remember, tessera};

#[tessera]
fn component() {
    let selected = remember(|| false);
    assert!(!selected.get());
    material_theme().child(move || {
        icon_button()
            .icon(filled::STAR_SVG)
            .filled_tonal()
            .selected(selected.get())
            .accessibility_label("Favorite")
            .on_click(move || selected.set(!selected.get()));
    });
}