Spinner
ui.widgets.Spinner短时加载状态的紧凑动画。
BEHAVIOR CONTRACT
尺寸、颜色和持续帧调度由动画管理器统一驱动。
RECORDED INTERACTION
录像保留动态帧,证明不是静态占位图。
// ── Spinner ──
pub fn buildSpinner(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
const a = cx.allocator;
const r = try row(cx, 20);
// e2e 墨量断言要框到 spinner 本身:story.<key> 的 rect 还含标题/描述文字,
// 那些文字的像素会把 spinner 画不出来这件事完全盖住(实测 7600+ dark)。
r.meta.ownership.meta.test_id = "story.spinner.row";
try r.appendChild(a, try W.Spinner(.{ .size = 16 }).mount(scope, cx));
try r.appendChild(a, try W.Spinner(.{ .size = 24 }).mount(scope, cx));
try r.appendChild(a, try W.Spinner(.{ .size = 36 }).mount(scope, cx));
return r;
}这是 Storybook 中该 story 的原样代码(zenit 5f9add5+wip 2026-09-30)。其中 W 即 ui.widgets,col / row / label 是 Storybook 内的布局小工具。
SpinnerProps
ui.widgets.Spinnerfn Spinner(props: SpinnerProps) SpinnerBuilder字段
类型
默认值
说明
sizef3220外径(逻辑像素)
stroke_widthf323线宽
color?Colornull弧线颜色(null = 使用主题 accent 色)
*Node
ui.widgets.Spinnermount 直接返回 *Node,把它 append 到父节点即可。