---
title: "Skeleton 组件 — zenit Zig UI"
description: "内容尚未到达时的占位骨架。text / rect / circle 变体、圆角和 shimmer 使用主题化视觉。"
url: https://zenit.z.express/zh/components/skeleton
language: zh-CN
alternate_en: https://zenit.z.express/components/skeleton.md
alternate_es: https://zenit.z.express/es/components/skeleton.md
alternate_ja: https://zenit.z.express/ja/components/skeleton.md
alternate_ko: https://zenit.z.express/ko/components/skeleton.md
alternate_fr: https://zenit.z.express/fr/components/skeleton.md
alternate_de: https://zenit.z.express/de/components/skeleton.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# Skeleton

`ui.widgets.Skeleton`

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

[Video](https://zenit.z.express/media/stories/skeleton.mp4?v=64767cb17e)

**BEHAVIOR CONTRACT**

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

**RECORDED INTERACTION**

录像展示真实 shimmer 动画。

`examples/storybook/stories.zig:651`

```zig
// ── 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](https://github.com/version-next/zenit/blob/HEAD/examples/storybook/stories.zig#L651)

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

### SkeletonProps

`ui.widgets.Skeleton`

[src/ui/components/skeleton/mod.zig:35](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/skeleton/mod.zig#L35)

```zig
fn Skeleton(props: SkeletonProps) SkeletonBuilder
```

| 字段 | 类型 | 默认值 | 说明 |
| --- | --- | --- | --- |
| `variant` | `SkeletonVariant` `.text` `.circular` `.rectangular` | `.text` | — |
| `width` | `f32` | `200` | — |
| `height` | `f32` | `16` | — |
| `animate` | `bool` | `true` | — |
| `count` | `u8` | `1` | — |
| `gap` | `f32` | `8` | — |

### \*Node

`ui.widgets.Skeleton`

mount 直接返回 `*Node`，把它 append 到父节点即可。
