components/skeleton
数据展示 · 25 / 64

Skeleton

ui.widgets.Skeleton

内容尚未到达时的占位骨架。

BEHAVIOR CONTRACT

text / rect / circle 变体、圆角和 shimmer 使用主题化视觉。

RECORDED INTERACTION

录像展示真实 shimmer 动画。

examples/storybook/stories.zig:651
// ── Skeleton ──
pub fn buildSkeleton(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 12);
    // 同 spinner:框到骨架图形本身,避开标题/描述文字的像素。
    c.meta.ownership.meta.test_id = "story.skeleton.col";
    try c.appendChild(a, try W.Skeleton(.{ .variant = .text, .width = 280, .height = 14 }).mount(scope, cx));
    try c.appendChild(a, try W.Skeleton(.{ .variant = .text, .width = 200, .height = 14 }).mount(scope, cx));
    try c.appendChild(a, try W.Skeleton(.{ .variant = .circular, .width = 48, .height = 48 }).mount(scope, cx));
    try c.appendChild(a, try W.Skeleton(.{ .variant = .rectangular, .width = 280, .height = 80 }).mount(scope, cx));
    return c;
}
在 GitHub 查看源码examples/storybook/stories.zig:651

这是 Storybook 中该 story 的原样代码(zenit 5f9add5+wip 2026-09-30)。其中 W 即 ui.widgets,col / row / label 是 Storybook 内的布局小工具。

zenit · 双授权开源项目可按 GPL-3.0-only 免费使用;闭源或商业产品需要商业授权。可联系作者:zongyi.xzy#gmail.com(# 换成 @)zenit 5f9add5+wip 2026-09-30