components/accordion
Navigation · 36 / 64

Accordion

ui.widgets.Accordion

Abschnitte ein- und ausklappen.

BEHAVIOR CONTRACT

Exklusiv oder mehrfach geöffnet, expanded-Zustand, Tastaturaktivierung und Body-Lebensdauer sind konsistent.

RECORDED INTERACTION

Der Harness klappt Section Two auf.

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;
}
Quellcode auf GitHub ansehenexamples/storybook/stories.zig:2323

Der unveränderte Quellcode der Story aus dem Storybook (zenit 5f9add5+wip 2026-09-30). W steht für ui.widgets; col / row / label sind kleine Layout-Helfer des Storybooks.

zenit · DoppellizenzKostenlos für Open-Source-Projekte unter GPL-3.0-only; Closed-Source- oder kommerzielle Produkte benötigen eine kommerzielle Lizenz.Kontakt zum Autor: zongyi.xzy#gmail.com (# durch @ ersetzen)zenit 5f9add5+wip 2026-09-30