Import
use maccn::MacSwitch;Usage
MacSwitch::new("wifi")
.checked(true)
.on_change(|next, _, _, _| {
println!("Switched to: {}", next);
})
.child("Wi-Fi");Sizes
use gpui::div;
use maccn::{MacControlSize, MacSwitch};
div()
.flex()
.items_center()
.gap_2()
.child(MacSwitch::new("switch-xl").size(MacControlSize::ExtraLarge).checked(true))
.child(MacSwitch::new("switch-l").size(MacControlSize::Large).checked(true))
.child(MacSwitch::new("switch-r").checked(true))
.child(MacSwitch::new("switch-s").size(MacControlSize::Small).checked(true))
.child(MacSwitch::new("switch-m").size(MacControlSize::Mini).checked(true))Disabled
use gpui::div;
use maccn::MacSwitch;
div()
.flex()
.flex_col()
.gap_2()
.child(MacSwitch::new("switch-d1").disabled(true).child("Disabled"))
.child(
MacSwitch::new("switch-d2")
.checked(true)
.disabled(true)
.child("Disabled on"),
)API
Props
| Prop | Type | Default |
|---|---|---|
size | MacControlSize | Regular |
checked | bool | false |
disabled | bool | false |
Events
| Event | Payload |
|---|---|
on_change | (bool, &ClickEvent, &mut Window, &mut App) |