-
Notifications
You must be signed in to change notification settings - Fork 9
Component ToggleButton
MeowLynxSea edited this page Jun 13, 2026
·
5 revisions
A button with a "selected" state. Like Button plus a selected(bool) and on_toggle(bool, …) instead of on_click.
use yororen_ui::headless::toggle_button::toggle_button;use yororen_ui::headless::toggle_button::toggle_button;
toggle_button("bold", cx)
.caption("B")
.selected(self.bold)
.on_toggle({
let entity = cx.entity();
move |new: bool, _window, cx| {
entity.update(cx, |s, _cx| s.bold = new);
}
})
.render(cx)| Method | Purpose |
|---|---|
caption(text) |
Button label. |
icon(source) |
Optional leading IconSource. |
icon_size(px) |
Size of the leading icon. |
caption_icon(text, source) |
Convenience: set both caption and icon in one call. |
variant(v) |
One of the ActionVariantKind values. |
selected(v) |
Current toggled state. |
disabled(v) |
Disable the toggle. |
on_toggle(closure) |
Fn(bool, &mut Window, &mut App) + 'static + Send + Sync. Fired with the new state. |
- Factory takes
(id, cx). Thecxis needed for the focus handle. - No state entity. Capture self with
cx.entity().clone(). -
.render(cx)returnsStateful<Div>.
Button, IconButton, Switch, Checkbox
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.