Skip to main content

checkbox

Function checkbox 

Source
pub fn checkbox<S, R>(
    text: impl Into<String>,
    checked: Sig<S, bool, R>,
) -> El<S>
Expand description

A checkbox labeled text, bound to checked.

It is a native <input type="checkbox"> inside the <label> that holds the text, so it needs no id, and it works on a field of a list item.

use hypersig::Signals;
use hypersig_ui::checkbox;
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct Terms {
    accepted: bool,
}

let accept = checkbox::<Terms, _>("I accept the terms", Terms::accepted());
assert!(accept.render().contains(r#"type="checkbox""#));