Skeleton
Loading placeholders in the shape of the real content, captured by boneyard.
Wrap the content in a Skeleton, name it, and set loading. boneyard’s
CLI renders the page in a browser at a few widths, measures every piece of the content and saves
those measurements as bones. While loading, the bones stand in, in the system’s muted color and
pulse, and the content keeps its space so nothing moves when it arrives. Turn the switch off to
see what they stand in for.
Capturing bones
Capture once, and again when the content’s layout changes. Point the CLI at a page that shows the skeleton, then import the registry it writes once, where your app starts.
Vite apps can use boneyardPlugin() from boneyard-js/vite instead, which captures as the dev
server runs. Without bones, a Skeleton shows its fallback while loading.
Single bones
Where there’s nothing to measure, like an iframe or an image still downloading, size a
SkeletonBone with classes. Bones are hidden from screen readers, so give the group a status
role and a label.
Dependencies
What it's built from and what's built from it in Base, read from the imports in its source.
| Uses | Nothing else in the system. |
|---|---|
| Used by | Nothing yet. |
| Packages | boneyard-js@1.10.0 |
Installation
Set the project up for Base once first, as Getting started shows. Then add it with the CLI, or by hand.
With the CLI
Manually
Install its packages:
Then copy the source:
API reference
Generated from Base's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.
Skeleton
Shows its captured bones while loading, and its children after. Name it so the CLI can find it, or pass initialBones. The content keeps its space while hidden, so nothing moves when it arrives.
- children*
Your component — rendered when not loading.
Type ReactNode
- className
Additional className for the container
Type string
- fallback
Shown when loading is true and no bones are available.
Type ReactNode
- fixture
Mock content rendered during
npx boneyard-js buildso the CLI can capture bone positions even when real data isn't available. Only rendered when the CLI setswindow.__BONEYARD_BUILD = true.Type ReactNode
- initialBones
Pre-generated bones. Accepts a single
SkeletonResultor aResponsiveBonesmap.Type SkeletonResult | ResponsiveBones
- loading*
When true, shows the skeleton. When false, shows children.
Type boolean
- name
Name this skeleton. Used by
npx boneyard-js buildto identify and capture bones. Also used to auto-resolve pre-generated bones from the registry.Type string
- select
Which width selects the responsive breakpoint:
'container'(default, the skeleton's measured width) or'viewport'(window.innerWidth, how the CLI keys captures). Use'viewport'for app-shell layouts where the container is narrower than the window. See #92.Type "container" | "viewport"
- snapshotConfig
Controls how
npx boneyard-js buildextracts bones from the fixture. Stored as a data attribute — the CLI reads it during capture.Type SnapshotConfig
SkeletonBone
A single bone you size with classes, for content there's nothing to capture from. Hidden from screen readers.
Takes the props of a native div.