Progress
ui.widgets.Progress確定的な進捗と不確定なタスク状態。
BEHAVIOR CONTRACT
パーセンテージ、status、height、不確定アニメーションを一つのコンポーネントで表現します。
RECORDED INTERACTION
25 / 60 / 100、error、不確定状態を示します。
// ── 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 内の小さなレイアウトヘルパーです。
ProgressProps
ui.widgets.Progressfn Progress(props: ProgressProps) ProgressBuilderフィールド
型
デフォルト値
説明
valuef320当前值 (0-100)
statusProgressStatus.normal.success.@"error".normal状态
heightf324轨道高度
show_textboolfalse显示百分比文本
indeterminateboolfalse不确定模式
width?f32null总宽度 (null = grow)
*Node
ui.widgets.Progressmount は *Node を直接返します。親ノードに append してください。