-
Notifications
You must be signed in to change notification settings - Fork 9
Component Checkbox
MeowLynxSea edited this page Feb 14, 2026
·
6 revisions
A boolean input.
Checkbox can be used in two ways:
- Controlled: you own
checkedand update it fromon_toggle. - Uncontrolled: omit
on_toggleand let the checkbox manage its own internal state.
use gpui::ElementId;
use yororen_ui::component::checkbox;
let view = checkbox()
.key(("settings", "auto-save"))
.checked(true)
.on_toggle(|checked, _ev: Option<&gpui::ClickEvent>, _window, _cx| {
// ...
});- Settings toggles where “on/off” is a simple boolean
- Multi-select lists
-
checkbox(): constructor -
id(...) / key(...): stable identity -
checked(bool): set current value -
disabled(bool): disable interaction + apply disabled styles -
tone(Hsla): override the checked accent color -
on_toggle(|checked, ev: Option<&gpui::ClickEvent>, window, cx| ...): fired on click,evisSome(event)for user clicks,Nonefor programmatic changes
- If
on_toggleis not provided, Checkbox uses internal keyed state and toggles itself. - If
on_toggleis provided, Checkbox becomes controlled and callson_toggle(!checked, ...).
- Size:
18x18 - Border:
theme.border.default(unchecked), accent when checked - Background:
- unchecked:
theme.surface.base - checked: accent color (
tone(...)ortheme.action.primary.bg)
- unchecked:
- Checkbox is focusable and shows a focus-visible border.
When you omit on_toggle, Checkbox manages its own internal state (keyed by id/key).
use yororen_ui::component::checkbox;
let view = checkbox().key(("demo", "auto-save")).checked(true);use gpui::rgb;
use yororen_ui::component::checkbox;
let view = checkbox().checked(true).tone(rgb(0x2F63FF));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.