Skip to content

ActionButton

A button that runs an action.

Example

Show code
use crate::data::count_products;
use zeyn::prelude::*;

pub fn overview(_ctx: &Ctx) -> Node {
    ActionButton::new("Count products", count_products, ())
        .on_success(|n, ui| {
            if let Ok(n) = n {
                ui.toast(format!("{n} products"));
            }
        })
        .into()
}