components/accordion
Navigation · 36 / 64

Accordion

ui.widgets.Accordion

Collapse and expand sections.

BEHAVIOR CONTRACT

Exclusive or multi-open, expanded state, keyboard activation and body lifetime are consistent.

RECORDED INTERACTION

The harness expands Section Two.

examples/storybook/stories.zig:2323
// ── Accordion ──
pub fn buildAccordion(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const acc = try W.Accordion(.{ .exclusive = false, .gap = 8 }).mount(scope, cx);
    inline for (.{ "Section One", "Section Two", "Section Three" }, 0..) |title, i| {
        const item = try W.AccordionItem(.{ .title = title, .expanded = (i == 0) }).mount(scope, cx);
        try item.body.appendChild(a, try ui.text(cx, "Panel body content.", .{ .font_size = 13, .color = light.color.fg_secondary }));
        try acc.container.appendChild(a, item.item);
    }
    return acc.container;
}
View source on GitHubexamples/storybook/stories.zig:2323

The story's verbatim source from the Storybook (zenit 4c50245 2026-10-01). W is ui.widgets; col / row / label are small Storybook layout helpers.

zenit · Dual-licensedFree for open-source projects under GPL-3.0-only; closed-source or commercial products need a commercial license.Contact the author: zongyi.xzy#gmail.com (replace # with @)zenit 4c50245 2026-10-01