Function freya::components::Radio

pub fn Radio(__props: RadioProps) -> Option<VNode>
Expand description

Controlled Radio component.

§Styling

Inherits the RadioTheme theme.

§Example

#[derive(PartialEq)]
enum Choice {
    FirstChoice,
    SecondChoice,
}

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