组件

Skeleton

A placeholder someone sketched in pencil: a pale hatch inside a rough ruled outline that boils gently between three redrawn frames. It costs no ink per instance, so a page of hundreds is as cheap as one.

安装

terminal
npx shadcn@latest add @wobko/skeleton

第一次使用?先把 registry 加进 components.json。 如何安装

示例

Shapes

Whatever shape the class says: text lines, a circle for an avatar, a picture, a row of buttons. Watch one for a few seconds: the outline and the hatch are redrawn three times over, slowly.

A card that has not arrived

The skeleton of a profile card placed inside the real Card, so the page does not jump when the words come in.

From loading to loaded

The skeleton and the content occupy the same room, so nothing moves when the swap happens. The region says it is busy while it waits; press Reload to see it again.

Demo

Official `skeleton-demo`: an avatar circle beside two lines of text, shaped only by classes. Each placeholder is a pale pencil hatch inside a rough outline that redraws itself slowly (three frames, each starting at its own phase); reduced motion holds it still.

Card

Official `skeleton-card`: a picture-sized block over two lines of text. The same one-line classes, no props; hundreds of these on a page cost about what one does, because the drawing is CSS masks from a few shared tiles.

API 参考

Skeleton

An empty div. Shape it with classes exactly as with shadcn's (h-4 w-[250px], size-12 rounded-full). The pencil is CSS: the hatch and the outline are masks made from a few tiny drawn tiles, defined once per page in one hoisted stylesheet; three redrawn frames of each are stepped through slowly. A rounded-full box gets a drawn circle.

属性类型默认值说明
classNamestring-Its size and shape: any width and height, rounded-full for a circle. Colors are the theme's pencil and paper tokens.
seedstring | number-Picks the phase of the boil this skeleton starts on, so a page of them does not flicker in unison. Default: derived from useId().

无障碍

  • A skeleton is an empty element, invisible to assistive tech, as shadcn's. Mark the region that is loading with aria-busy="true" (and a status or a visually hidden "Loading" for screen readers), and remove the skeletons when the content arrives.
  • Nothing in it is interactive or focusable; the boil is decoration, and a page of skeletons never announces anything.
  • Reduced motion (the OS setting or the in-app calm-ink setting) and calm density hold the first frame still.
  • In Windows high contrast the drawing is replaced by a dashed system-color outline.
  • The masks need CSS mask-image (every current browser); the stylesheet is injected with <style href precedence>, so React 19 hoists it, dedupes it and includes it in server HTML.

源码

CLI 会复制进你项目的文件。

正在加载源码