Skip to main content

Button

Function Button 

Source
pub fn Button<F, G>(
    __arg0: Modifier,
    __arg1: ButtonSpec,
    __arg2: F,
    __arg3: 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.
  • spec - Configuration for button behavior.
  • 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),
    ButtonSpec::default(),
    || println!("Clicked!"),
    || Text("Click Me", Modifier::empty())
);