Toggle
FormA switch/toggle control — styled wrapper around Iced's toggler widget.
Preview
Enabled
Disabled
Usage
toggle.rs
use floe_ui::components::toggle;
"text-zinc-500">// Toggle with label
let t = toggle::styled(Some("Airplane mode".to_string()), self.is_toggled, &tokens)
.on_toggle(Message::Toggled);
"text-zinc-500">// Toggle without label
let t2 = toggle::styled(None::<String>, self.dark_mode, &tokens)
.on_toggle(Message::DarkModeToggled);API Reference
Props / Parameters
| Name | Type | Description |
|---|---|---|
| label | impl Into<Option<String>> | Optional label text |
| is_toggled | bool | Current toggle state |
| tokens | &DesignTokens | Design tokens for theming |
Style Functions
default_style(tokens)
Style functions return closures compatible with Iced's .style() method.
Builder Functions
styled(label, is_toggled, tokens)
Builder functions return pre-configured Iced widgets ready for use.
Source: floe-ui/src/components/toggle.rs