Skeleton
Shows a placeholder while content is loading.
Installation
Install the following dependencies:
Set up the token layer and the StyleX compiler, if you have not already. See Installation.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
Usage
A skeleton has no size of its own. Give it the width and height of the content
it stands in for through xstyle, or through style when only the runtime
knows them.
A band of light sweeps across every skeleton on the page at once. The gradient
is laid out against the viewport rather than each block, so an avatar and the
lines beside it share one pass. Under prefers-reduced-motion the sweep becomes
a slow fade.
Avatar
Card
Text
Form
Table
API reference
Pass render to replace a part's element or compose it with another component.
Skeleton renders a <div> and accepts every <div> attribute.
Skeleton
| Prop | Type | Default |
|---|---|---|
xstyle | StyleXStyles | — |
style | CSSProperties | — |
className | string | — |
The pulse keeps running under prefers-reduced-motion: reduce. It is an
opacity fade with nothing moving across the block. A still grey block would
look empty rather than loading.
skeletonStyles
The style maps behind the component. Spread them onto any element.
| Key | What it is |
|---|---|
base | The muted fill, rounding and the pulse |
Data attributes
| Attribute | On | Effect |
|---|---|---|
data-slot="skeleton" | the block | Targets the block from a parent |