Overview
Reference usage
Animated placeholder shape that fills content areas while data is loading.
Usage
Lines and variants
lines stacks text bars, and the last bar is shorter unless you pass width. variant="card" draws a heading bar and the lines inside a bordered card. Both match the real layout, so the page does not shift when content arrives:
Form variant
variant="form" draws rows fields, each a short label bar over a full-width control bar at the control height, for the input of a form that is still loading. It takes stillLoadingAfter, onCancel and label like the other groups.
List variant
variant="list" draws the placeholder for a status-first list in the real layout: a bordered surface of rows rows (default 3), each with the 8rem status column reserved, two text bars and a time bar at the right. No leading circle or avatar is drawn, so nothing shifts when the data arrives. dayBand adds a tinted day band above the rows for a list grouped by day. On a narrow container the status bar drops under the text bars, as a stacked list item does on a phone.
label names the loading region (for example "Loading agents"). The bars stay hidden from assistive technology, no spinner is drawn, and the name is announced politely when the rows appear:
Loading rules
Cinder's loading rules are timing rules, and Skeleton implements them so each view does not rebuild them:
- Show nothing for the first 300 ms, so a fast load never flashes a placeholder (
delay={300}). - Show the skeleton in the real layout until 10 seconds have passed.
- After 10 seconds, add a "Still loading" status with a Cancel button (
stillLoadingAfter={10000}andonCancel).
The status is Skeleton's own line below the placeholders, centred in the list variant, and never a banner. The header and filters of the page stay live. The default text is the shared line, "Still loading. This is taking longer than usual."; a page replaces it with its own noun through stillLoadingLabel, for example "Still loading runs. This is taking longer than usual.". Cancel is a ghost button that appears only when onCancel is set.
When the loading state is the shape of a whole page (real labels and headings with placeholder values and rows), give the Skeleton children. They are drawn instead of the bars, in a group marked busy, and the group keeps the timing: nothing is drawn until delay, and the status line follows the content. Draw each placeholder block with a Skeleton of its own; text in the children is read as written.
Both timers start when the Skeleton mounts, so render it only while the request is pending and unmount it when the request settles. Unmounting clears the timers. stillLoadingAfter counts from mount, not from the end of delay. Without delay or stillLoadingAfter a Skeleton renders immediately and never shows a status, exactly as a plain block always has.
When to use
- Reserving the rough shape of incoming content during an initial fetch to avoid layout shift.
- Indicating progressive load of cards, rows, or media tiles where the final shape is known.
- Indicating indeterminate background work without a known target shape — use spinner.
- Communicating that a view has no data at all — use empty-state.
Examples
Skeleton placeholders
Animated loading placeholders for text and avatars.
Lines and card
lines stacks text bars; variant="card" draws a heading bar and lines inside a card.
List loading and slow loading
The list variant keeps each row’s status column reserved, then draws two text bars and a time bar, with no circle, so nothing shifts when the data arrives. The region is announced as "Loading agents" with no spinner. After the slow-loading time its own status line and a ghost Cancel appear below the rows; it is not a banner.
Loading rules
Nothing for 300 ms, the skeleton until 10 seconds, then Still loading with Cancel.
Props
Name | Type | Default | Description |
|---|---|---|---|
width | text | CSS width value applied as an inline style on the skeleton block (e.g. '200px', '100%'). | |
height | text | CSS height value applied as an inline style on the skeleton block (e.g. '1rem', '48px'). | |
radius | text | CSS border-radius value applied as an inline style, overriding the default pill shape (e.g. '4px', '50%'). | |
lines | number | 1 | Number of text bars to stack. More than one renders a group, and the last bar is shorter
unless width is set. Clamped to between 1 and 20. |
variant | 'row' | 'card' | 'list' | 'form' | 'row' | Shape of the group. 'row' stacks the bars directly; 'card' wraps a heading bar and the
lines bars in a bordered card; 'list' draws rows status-first list rows; 'form' draws
rows fields, a label bar over a control bar each. |
rows | number | 3 | Number of fields to draw when variant is 'form', and of list rows when it is 'list'. Each row keeps the 8rem status
column reserved, then shows two text bars and a time bar, with no leading circle, so
nothing shifts when data arrives. Clamped to between 1 and 20. Ignored by other variants. |
statusMarker | 'bar' | 'dot' | 'bar' | What fills the status column of each row when variant is 'list'. 'bar' is a short bar
where the status word reads; 'dot' is a small circle where the status dot sits. The column
keeps its width either way, so nothing shifts when data arrives. Ignored by other variants. |
statusColumn | boolean | true | Keep the 8rem status column that every status-first list shares when variant is 'list'.
Turn it off for a list whose rows do not lead with a status word, such as a card of problems
with a glyph and an action: the marker then sits right before the text, so the placeholder
matches the row it stands for. Ignored by other variants. |
framed | boolean | true | Draw the list's own border and rounded corners when variant is 'list'. Turn it off inside
a card that already frames its rows, so the placeholder does not draw a box within the box.
Ignored by other variants. |
dayBand | boolean | false | Draw a day band (a tinted header with one bar) above the rows when variant is 'list',
the placeholder for a list that groups its rows by day. Ignored by other variants. |
label | text | Accessible name of the loading region, announced politely once the placeholder appears
(for example 'Loading agents'). The placeholder bars stay hidden from assistive
technology and no spinner is drawn. Applies to the grouped variants; omit it when the
surrounding region already says what is loading. | |
delay | number | 0 | Milliseconds to wait after mounting before anything renders. A load that finishes inside
the delay never flashes a placeholder. Use 300 for the Cinder loading rule. |
stillLoadingAfter | number | Milliseconds after mounting at which a "Still loading" status replaces silence, with a
Cancel button when onCancel is set. Counted from mount, not from the end of delay.
Use 10000 for the Cinder loading rule. Omit to never show the status. | |
onCancel | () => void | Called when the Cancel button in the "Still loading" status is pressed. The button renders only when this is set. | |
stillLoadingLabel | text | 'Still loading. This is taking longer than usual.' | Text of the "Still loading" status. Pages replace the default with their own noun, for
example 'Still loading runs. This is taking longer than usual.'. |
cancelLabel | text | 'Cancel' | Label of the Cancel button in the "Still loading" status. |
children | snippet | The page's own placeholder, drawn instead of the bars, for a loading state whose shape is a
whole page (real labels and headings with placeholder values and rows). The group still owns
the timing: nothing is drawn until delay has passed, and the "Still loading" status follows
the content after stillLoadingAfter. The group is marked busy while it shows. Draw each
placeholder block with a Skeleton of its own; the content is not hidden from assistive
technology, so text in it is read as written. |