Skip to main content

Checkbox

Function Checkbox 

Source
pub fn Checkbox(_: CheckboxProps) -> Element
Expand description

A checkbox row: the box, a label, and optional helper and error text. The whole row is the control. Like Ionic’s ion-checkbox.

let agreed = use_signal(|| false);
rsx! {
    Checkbox { checked: agreed, label: "I agree to the terms",
        error: (!agreed()).then(|| "Required".to_string()) }
}

§Props

For details, see the props struct definition.

  • checked : Option<Signal<bool>>

    Whether it is checked. Kept internally when not given.

  • label : Option<String>

    Visible label, which also names the checkbox.

  • aria_label : Option<String>

    Accessible name when there is no visible label.

  • indeterminate : Option<bool>

    Show a dash for a partly selected group. Pressing still toggles checked.

  • helper : Option<String>

    Help text under the label.

  • error : Option<String>

    Error text under the label. Marks the checkbox invalid when not empty.

  • disabled : Option<bool>

    Disable the checkbox.

  • label_placement : Option<ControlLabelPlacement>

    Label position. Defaults to ControlLabelPlacement::Start.

  • onchange : Option<EventHandler<bool>>

    Called with the new state.

  • id : Option<String>

    Element id. Generated when not given.

  • mode : Option<ComponentMode>

    Platform look. Defaults to the ambient mode.

  • class : Option<String>

    Extra classes for the row.