ui_storybook/components/primitives/
toggle_switch.rs1use leptos::prelude::*;
8
9#[component]
10pub fn ToggleSwitch(
11 checked: bool,
13 #[prop(optional)]
15 disabled: bool,
16 #[prop(into)]
18 label: String,
19) -> impl IntoView {
20 let mut class = String::from("toggle");
21 if checked {
22 class.push_str(" toggle-on");
23 }
24 if disabled {
25 class.push_str(" toggle-disabled");
26 }
27 view! {
28 <button
29 class=class
30 role="switch"
31 aria-checked=checked
32 aria-label=label
33 disabled=disabled
34 >
35 <span class="toggle-track">
36 <span class="toggle-knob"></span>
37 </span>
38 </button>
39 }
40}