Skip to main content

Button

Function Button 

Source
pub fn Button<F, G>(__arg0: Modifier, __arg1: F, __arg2: G) -> NodeId
where F: FnMut() + 'static, G: FnMut() + 'static,
Expand description

A clickable button with a background and content.

§When to use

Use this to trigger an action when clicked. The button serves as a container for other composables (typically Text).

§Arguments

  • modifier - Modifiers to apply to the button container (e.g., size, padding).
  • on_click - The callback to execute when the button is clicked.
  • content - The content to display inside the button (e.g., Text or Icon).

§Example

Button(
    Modifier::padding(8.0),
    || println!("Clicked!"),
    || Text("Click Me", Modifier::empty())
);