Function freya_components::Checkbox 
source · pub fn Checkbox(__props: CheckboxProps) -> ElementExpand description
Controlled Checkbox component.
§Styling
Inherits the CheckboxTheme theme.
§Example
#[derive(PartialEq, Eq, Hash)]
enum Choice {
    First,
    Second,
}
fn app() -> Element {
    let mut selected = use_signal::<HashSet<Choice>>(HashSet::default);
    rsx!(
        Tile {
            onselect: move |_| {
                if selected.read().contains(&Choice::First) {
                    selected.write().remove(&Choice::First);
                } else {
                    selected.write().insert(Choice::First);
                }
            },
            leading: rsx!(
                Checkbox {
                    selected: selected.read().contains(&Choice::First),
                },
            ),
            label { "First choice" }
        }
        Tile {
            onselect: move |_| {
                if selected.read().contains(&Choice::Second) {
                    selected.write().remove(&Choice::Second);
                } else {
                    selected.write().insert(Choice::Second);
                }
            },
            leading: rsx!(
                Checkbox {
                    selected: selected.read().contains(&Choice::Second),
                },
            ),
            label { "Second choice" }
        }
    )
}