-
Notifications
You must be signed in to change notification settings - Fork 9
Component Switch
MeowLynxSea edited this page Jan 24, 2026
·
6 revisions
A toggle switch.
Switch can be controlled or uncontrolled:
- Controlled: provide
checked+on_toggle. - Uncontrolled: omit
on_toggleand the switch manages its own state.
use gpui::ElementId;
use yororen_ui::component::switch;
let view = switch()
.key(("settings", "notifications"))
.checked(true)
.on_toggle(|checked, _ev, _window, _cx| {
// ...
});- Modern on/off toggles in settings
-
switch(): constructor -
id(...) / key(...): stable identity checked(bool)disabled(bool)-
tone(Hsla): override accent when checked on_toggle(|checked, ev, window, cx| ...)
- Track size:
34x18 - Knob size:
14x14 - Accent when checked:
tone(...)ortheme.action.primary.bg
- Switch is focusable and shows a focus-visible border.
use yororen_ui::component::switch;
let view = switch().key(("demo", "notifications")).checked(false);Yororen UI v0.3.0 · repository · Apache-2.0 · This wiki documents Yororen UI v0.3.0.
This wiki documents Yororen UI v0.3.0 — the headless-core, swappable-renderer build.