Progress
ui.widgets.Progress确定进度与不确定任务状态。Determinate and indeterminate progress.
BEHAVIOR CONTRACT
百分比、status、height 与 indeterminate 动画由同一组件表达。Percent, status, height and the indeterminate animation are one component.
RECORDED INTERACTION
录像展示 25 / 60 / 100、error 和不确定态。Shows 25 / 60 / 100, error and indeterminate.
// ── Progress ──
pub fn buildProgress(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
const a = cx.allocator;
const c = try col(cx, 16);
try c.appendChild(a, try label(cx, "Values 25% / 60% / 100%"));
try c.appendChild(a, try W.Progress(.{ .value = 25, .width = 320, .show_text = true }).mount(scope, cx));
try c.appendChild(a, try W.Progress(.{ .value = 60, .width = 320, .show_text = true }).mount(scope, cx));
try c.appendChild(a, try W.Progress(.{ .value = 100, .width = 320, .status = .success, .show_text = true }).mount(scope, cx));
try c.appendChild(a, try label(cx, "Heights (2 / 4 / 8 / 12)"));
inline for (.{ 2, 4, 8, 12 }) |h| {
try c.appendChild(a, try W.Progress(.{ .value = 50, .width = 320, .height = @as(f32, h) }).mount(scope, cx));
}
try c.appendChild(a, try label(cx, "Error / indeterminate / no-text"));
try c.appendChild(a, try W.Progress(.{ .value = 40, .width = 320, .status = .@"error", .show_text = true }).mount(scope, cx));
try c.appendChild(a, try W.Progress(.{ .indeterminate = true, .width = 320 }).mount(scope, cx));
try c.appendChild(a, try W.Progress(.{ .value = 70, .width = 320, .show_text = false }).mount(scope, cx));
return c;
}这是 Storybook 中该 story 的原样代码(zenit 5f9add5+wip 2026-09-30)。其中 W 即 ui.widgets,col / row / label 是 Storybook 内的布局小工具。The story's verbatim source from the Storybook (zenit 5f9add5+wip 2026-09-30). W is ui.widgets; col / row / label are small Storybook layout helpers.