euv_ui/hook/use_boolean/struct.rs
1use super::*;
2
3/// A reactive boolean toggle with a caller-chosen initial value.
4///
5/// The existing [`Toggle`] type always starts as `false`, which is the
6/// right default for a switch but the wrong one for a dialog that opens
7/// already expanded. This type is the same toggle with the initial
8/// value chosen by the caller.
9///
10/// The current value is exposed as a `Signal<bool>` accessed through
11/// `get_value()`. Any `html!` body that reads `toggle.get_value().get()`
12/// inside its render closure re-renders when the value changes.
13#[derive(Clone, Data, Debug, Default, New)]
14pub struct UseBoolean {
15 /// The current value signal.
16 ///
17 /// Defaults to `Signal::create(false)` via `#[new(skip)]`; the hook
18 /// overwrites it with the requested initial value.
19 #[new(skip)]
20 #[get(type(copy))]
21 #[set(skip)]
22 pub value: Signal<bool>,
23}