Web · Components
Skeleton
Faded box holding the place of content while it loads; prevents layout shift (CLS) when the content arrives.
4 exports
Live example
Preview
Code
Events
- Events appear here when you interact with the preview.
Import
Faded box holding the place of content while it loads; prevents layout shift (CLS) when the content arrives. It is a server component.
Three uses:
- Box: give the size with classes or
width/height;shape="circle"for an avatar,shape="text"for a single line. - Paragraph:
lines={3}; the last line stays short. - Automatic: wrap the real component with
loading; texts, images and buttons turn into faded boxes in the same place. No need to write a separate placeholder layout.
Hidden from screen readers; announce the loading state on the container with aria-busy. With the "reduced motion" preference the motion stops.
Examples
SkeletonShape
typeShape of the placeholder.
rect: box with slightly rounded corners (card, image, button).circle: circle (avatar); ifwidthis given, the height equals it.text: a bar the height of a text line; follows the font size.
Motion of the placeholder.
pulse: slowly fades and darkens.shimmer: a shine moving from left to right.none: still.
With the "reduced motion" preference the motion always stops.
SkeletonProps
interfaceProps of the Skeleton component.
Extends: Omit<ComponentProps<"div">, "children">
| Name | Type | Default | Description |
|---|---|---|---|
shape? | SkeletonShape | "rect"`, `"text"` if `lines` is given | Shape. See SkeletonShape. |
lines? | number | Text paragraph: draws this many lines; the last line is shorter. Lines follow the container's width. | |
width? | number | string | Width: a number is pixels, text is a CSS value ("60%", "12rem"). | |
height? | number | string | Height: a number is pixels, text is a CSS value. | |
animation? | SkeletonAnimation | "pulse" | Animation. See SkeletonAnimation. |
loading? | boolean | true | With children: while true the content is drawn invisible and its texts, images and buttons turn into faded boxes of the same size; when false the content shows as is. No need to write a separate placeholder layout, and the page doesn't shift when the content arrives. Ideal for rendering with placeholder content (sample data). No effect without children. |
children? | ReactNode | Content whose shape is taken with loading. While loading it is non-interactive (inert) and hidden from screen readers. |