pub fn onclick<E: EventReturn<T>, T>(
    _f: impl FnMut(Event<MouseData>) -> E + 'static
) -> Attribute
Expand description

The click event fires when the user clicks an element with the mouse. Note that this fires for all mouse buttons. You can check the specific variant with the MouseData’s trigger_button property.

Event Data: MouseData

Example

fn app() -> Element {
    rsx!(
        rect {
            width: "100",
            height: "100",
            background: "red",
            onclick: |_| println!("Clicked!")
        }
    )
}