Radio
ui.widgets.RadioGroup排他的な選択肢から値を一つだけ選びます。
BEHAVIOR CONTRACT
グループ内の選択、value、name、矢印キー移動、フォーカス順はグループが管理します。
RECORDED INTERACTION
harness が Option Y を選ぶと、グループ内の他の項目は選択解除されます。
pub fn buildRadio(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
const a = cx.allocator;
const c = try col(cx, 16);
const status = try ui.text(cx, "selected → (none)", .{ .font_size = 13, .color = light.color.fg_secondary });
status.meta.ownership.meta.test_id = "story.radio.status";
try c.appendChild(a, status);
const radio_story = try cx.bindState(RadioStory, .{ .status = status });
try c.appendChild(a, try label(cx, "Radio"));
try c.appendChild(a, try W.Radio(.{ .label_text = "Selected", .checked = true, .value = "a", .name = "g" }).mount(scope, cx));
try c.appendChild(a, try W.Radio(.{ .label_text = "Unselected", .checked = false, .value = "b", .name = "g" }).mount(scope, cx));
try c.appendChild(a, try label(cx, "RadioGroup"));
const opts = [_]ui.widgets.checkbox.RadioOption{
.{ .value = "x", .label_text = "Option X" },
.{ .value = "y", .label_text = "Option Y" },
.{ .value = "z", .label_text = "Option Z" },
};
const group = try W.RadioGroup(.{
.options = &opts,
.value = "x",
.on_change = ui.Cx.strHandlerFrom(RadioStory, radio_story, RadioStory.onChange),
}).mount(scope, cx);
group.meta.ownership.meta.test_id = "story.radio.group";
try c.appendChild(a, group);
return c;
}Storybook にあるこの story のコードそのままです(zenit 5f9add5+wip 2026-09-30)。W は ui.widgets のことで、col / row / label は Storybook 内の小さなレイアウトヘルパーです。
RadioGroupProps
ui.widgets.RadioGroupfn RadioGroup(props: RadioGroupProps) RadioGroupBuilderフィールド
型
デフォルト値
説明
options[]const RadioOption—
—
value?[]const u8null—
name[]const u8""—
horizontalboolfalse—
disabledboolfalse—
on_change?core.HandlerRefnull—
state_id?u64null—
RadioProps
ui.widgets.Radiofn Radio(props: RadioProps) RadioBuilderフィールド
型
デフォルト値
説明
checkedboolfalse—
label_text?[]const u8null—
value[]const u8""—
name[]const u8""—
disabledboolfalse—
on_change?core.HandlerRefnull—
_skip_interactionboolfalse跳过内部交互注册(RadioGroup 统一管理时设 true)
*Node
ui.widgets.RadioGroupmount は *Node を直接返します。親ノードに append してください。
*Node
ui.widgets.Radiomount は *Node を直接返します。親ノードに append してください。