euv_ui/component/switch/view/struct.rs
1use super::*;
2
3/// Props for the `euv_switch` component.
4///
5/// Defines the strongly-typed interface for a toggle switch. The checked
6/// state is owned by the caller through a `Signal<bool>` so the switch can
7/// participate in two-way binding with the rest of the page.
8#[derive(Clone, CustomDebug, Data, Default, New)]
9pub struct EuvSwitchProps {
10 /// The unique identifier for the switch element.
11 #[get(type(copy))]
12 pub id: &'static str,
13 /// The HTML name attribute shared by switches in the same form group.
14 #[get(type(copy))]
15 pub name: &'static str,
16 /// The boolean signal bound to the switch checked state.
17 #[get(type(copy))]
18 pub checked: Signal<bool>,
19 /// The label text displayed next to the switch.
20 #[get(type(copy))]
21 pub label: &'static str,
22 /// Whether the switch is disabled.
23 #[get(type(copy))]
24 pub disabled: Signal<bool>,
25}
26
27/// The reactive state handle for the `euv_switch` component.
28///
29/// Registered against the current hook context slot via
30/// [`HookContext::use_hook`], so every render at the same hook index
31/// observes the same `Signal<bool>` and the switch keeps its state
32/// across re-renders.
33#[derive(Clone, Copy, CustomDebug, Data, Default)]
34pub struct EuvSwitchState {
35 /// The signal holding the switch checked state.
36 #[get(type(copy))]
37 pub checked: Signal<bool>,
38}