-
Notifications
You must be signed in to change notification settings - Fork 9
Component RadioGroup
MeowLynxSea edited this page Jan 24, 2026
·
4 revisions
A group of radio options.
RadioGroup renders a vertical list of selectable options. It can be used in controlled or uncontrolled mode.
use gpui::ElementId;
use yororen_ui::component::{radio_group, RadioOption};
let view = radio_group()
.key(("settings", "theme"))
.options([
RadioOption::new("light", "Light"),
RadioOption::new("dark", "Dark"),
])
.on_change(|value, _ev, _window, _cx| {
// ...
});- Small mutually exclusive sets (theme, mode, region)
-
radio_group(): constructor -
id(...) / key(...): stable identity -
options([...])/option(RadioOption) -
value(String): set selected value (controlled) -
disabled(bool): disable entire group -
tone(Hsla): set accent color for all radios -
on_change(|value, ev, window, cx| ...): fired when selection changes -
render_option(|option, radio| -> AnyElement): custom option row rendering
- If
on_changeandvalueare both omitted, the group manages its own selected value.
- Layout: vertical (
flex_col) with a small gap between options - Options are clickable rows by default; use
render_option(...)to supply a custom row layout
use gpui::div;
use yororen_ui::component::{label, radio_group, RadioOption};
let view = radio_group()
.options([
RadioOption::new("stable", "Stable"),
RadioOption::new("beta", "Beta"),
])
.render_option(|opt, radio| {
div()
.flex()
.items_center()
.justify_between()
.gap_3()
.child(div().flex().items_center().gap_2().child(radio).child(opt.label.clone()))
.child(label(opt.value.clone()).mono(true).muted(true))
.into_any_element()
});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.