Function freya::components::Switch

source ·
pub fn Switch<'a>(cx: &'a Scoped<'a, SwitchProps<'a>>) -> Option<VNode<'a>>
Expand description

Controlled Switch component.

Props

See SwitchProps.

Styling

Inherits the SwitchTheme theme.

Example

fn app(cx: Scope) -> Element {
    let enabled = use_state(&cx, || false);

    render!(
        Switch {
            enabled: *enabled.get(),
            ontoggled: |_| {
                enabled.set(!enabled.get());
            }
        }
    )
}