Skeleton骨架屏
查看源码components/skeleton.go内容占位#
使用圆角块表达标题与正文仍在加载。
title := f.Slot().FillWidth().MaxWidth(236).Height(22)
line1 := f.Slot().Height(14)
line2 := f.Slot().WidthPercent(82).Height(14)
line3 := f.Slot().WidthPercent(64).Height(14)
components.BeginSkeleton(canvas, theme, title.Rect()).Paint()
components.BeginSkeleton(canvas, theme, line1.Rect()).Radius(4).Paint()
components.BeginSkeleton(canvas, theme, line2.Rect()).Radius(4).Paint()
components.BeginSkeleton(canvas, theme, line3.Rect()).Radius(4).Paint()资料卡#
圆形头像与多行资料占位组合。
avatar := f.Slot().Size(56, 56)
name := f.Slot().Size(172, 16)
handle := f.Slot().Size(118, 12)
body := f.Slot().Height(92)
components.BeginSkeleton(canvas, theme, avatar.Rect()).Circle().Paint()
components.BeginSkeleton(canvas, theme, name.Rect()).Paint()
components.BeginSkeleton(canvas, theme, handle.Rect()).Radius(4).Paint()
components.BeginSkeleton(canvas, theme, body.Rect()).Paint()显式相位#
由调用方提供固定动画相位;组件自身不启动计时器。
rows := [4]flex.Box{}
for index := range rows {
rows[index] = f.Slot().Height(20)
}
for index, phase := range [...]float32{0, 0.25, 0.50, 0.75} {
components.BeginSkeleton(canvas, theme, rows[index].Rect()).Radius(5).Phase(phase).Paint()
}安装
将组件源码复制到自己的项目,直接修改。
go run ./cmd/viva add --out ./components/local skeleton源码组件用法#
此预览直接调用生产 Go 组件。稳定 ID、值与打开状态仍由应用持有;组件只负责绘制并声明交互语义。
- 标题旁的源码链接列出了全部选项与视觉决策。
- 请使用原生命令验证系统文本、焦点、无障碍与平台集成。
- 浏览器预览验证共享布局和场景行为,不代表原生性能。
验证边界#
示例覆盖当前 API 的代表性状态,但不表示每个桌面后端都已完成真机验证。
键盘操作
Tab 在控件间移动;Ctrl/⌘ K 搜索组件。进入预览后,键盘事件由 Go 运行时处理。