components/steps
Anzeige · 28 / 64

Steps

ui.widgets.Steps

Erledigte, aktuelle und ausstehende Zustände einer mehrstufigen Aufgabe.

BEHAVIOR CONTRACT

Horizontale und vertikale Layouts teilen sich den aktuellen Index und die Abschluss-Icons.

RECORDED INTERACTION

Zeigt Schritt 2 aktiv und den vertikalen Abschlusszustand.

examples/storybook/stories.zig:2372
// ── Steps ──
pub fn buildSteps(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const icons = ui.assets.common;
    const c = try col(cx, 24);
    const items = [_]W.StepItem{
        .{ .title = "Account", .description = "Create account" },
        .{ .title = "Profile", .description = "Fill details" },
        .{ .title = "Done", .description = "Finish" },
    };

    // 水平:completed step 用真实 check 图标(不传 check_icon_asset 时回退成 "v" 字符不美观)
    try c.appendChild(a, try label(cx, "Horizontal (step 2 active)"));
    try c.appendChild(a, try W.Steps(.{ .items = &items, .initial_current = 1, .check_icon_asset = icons.check }).mount(scope, cx));

    // 垂直
    try c.appendChild(a, try label(cx, "Vertical"));
    try c.appendChild(a, try W.Steps(.{ .items = &items, .initial_current = 2, .direction = .vertical, .check_icon_asset = icons.check }).mount(scope, cx));
    return c;
}
Quellcode auf GitHub ansehenexamples/storybook/stories.zig:2372

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