ICEN UI 骨架屏
Docs ⌘K
Core · 稳定

骨架屏

加载占位:呼吸脉冲的灰块,拼出内容轮廓。

Preview
反馈 skeleton
html
<div style="display:flex;align-items:center;gap:12px">  <div class="icen-skeleton icen-skeleton--circle" style="width:40px;height:40px"></div>  <div style="flex:1;display:flex;flex-direction:column;gap:8px">    <div class="icen-skeleton" style="height:12px;width:45%"></div>    <div class="icen-skeleton" style="height:12px;width:80%"></div>  </div></div><div class="icen-skeleton" style="height:12px;width:100%;margin-top:12px"></div><div class="icen-skeleton" style="height:12px;width:66%;margin-top:8px"></div>

特性

按真实内容的行高与宽度拼骨架,加载完成后整片替换,避免布局跳动。

安装

bun add @icen.ai/ui

一行引入该组件(CSS 与 behavior 自动带上,无需关心内部 CSS 文件名):

js
import '@icen.ai/ui/kit/skeleton';

也可以用脚手架直接打印引入行:

bash
bunx --bun @icen.ai/ui add skeleton

Astro 项目注意:kit 入口里的 CSS import 在页面 <script> 里会被 Astro 的 client bundle 摇掉——请改在布局 frontmatter 里引 CSS(import '@icen.ai/ui/components/feedback.css';),JS 行为仍可走 kit。Vite SPA / webpack 项目无此问题。

用法

html
<div class="icen-skeleton" style="height:12px;width:80%"></div><div class="icen-skeleton icen-skeleton--circle" style="width:40px;height:40px"></div>