Function freya_components::Switch
source · pub fn Switch(props: SwitchProps) -> Element
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(),
ontoggled: move |_| {
enabled.toggle();
}
})
}
§Preview
Enabled | Not Enabled |
---|---|
![Switch Enabled Demo][gallery_enabled_switch] | ![Switch Not Enabled Demo][gallery_not_enabled_switch] |