Function freya_components::Radio

source ·
pub fn Radio(_: RadioProps) -> Element
Expand description

Controlled Radio component.

§Styling

Inherits the RadioTheme theme.

§Example

#[derive(PartialEq)]
enum Choice {
    First,
    Second,
}

fn app() -> Element {
    let mut selected = use_signal(|| Choice::First);
    rsx!(
        Tile {
            onselect: move |_| selected.set(Choice::First),
            leading: rsx!(
                Radio {
                    selected: *selected.read() == Choice::First,
                },
            ),
            label { "First choice" }
        }
        Tile {
            onselect: move |_| selected.set(Choice::Second),
            leading: rsx!(
                Radio {
                    selected: *selected.read() == Choice::Second,
                },
            ),
            label { "Second choice" }
        }
    )
}

§Props

For details, see the props struct definition.

  • selected : bool

    Indicate whether this radio is selected or not.

  • theme : Option<RadioThemeWith>

    Theme override.