Skip to main content

button

Function button 

Source
pub fn button<S>(variant: ButtonVariant, size: ButtonSize) -> El<S>
Expand description

A <button type="button"> of variant and size.

The type is button, so that a button inside a form does not submit it. The one that should is a submit_button. Disable either with El::disabled, which dims it.

use hypersig::Signals;
use hypersig_ui::{ButtonSize, ButtonVariant, button};
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct Counter {
    count: i32,
}

let count = Counter::count();
let plus = button::<Counter>(ButtonVariant::Outline, ButtonSize::Sm)
    .on_click(count.set(count + 1))
    .disabled(count.ge(10))
    .text("Add one");
assert!(plus.render().contains(r#"type="button""#));