Function freya::components::Switch

source ·
pub fn Switch(props: SwitchProps) -> Result<VNode, RenderError>
Expand description

Display whether a state is true or false. Commonly used for enabled/disabled scenarios. Example: light/dark theme.

§Styling

Inherits the SwitchTheme theme.

§Example

fn app() -> Element {
    let mut enabled = use_signal(|| false);

    rsx!(Switch {
        enabled: *enabled.read(),
        ontoggled: move |_| {
            enabled.toggle();
        }
    })
}