Feedback

Skeleton

Decorative placeholder for loading content. Reserves the shape of text, cards, and wide or stacked tables, with optional delayed appearance and a loading status.

import { Skeleton } from '@lostgradient/cinder';
feedbackloading
01

Overview

Reference usage

Animated placeholder shape that fills content areas while data is loading.

Usage

svelte
<script lang="ts">
  import { Skeleton } from '@lostgradient/cinder';
</script>

<Skeleton />

Hold content under a bar

Pass a holds snippet to a single Skeleton when the placeholder needs to match the content's size and wrapping. The bar fits the content up to the available width and grows with its height. The held content is invisible, takes no focus and stays out of the accessibility tree. Pass width or height to override the corresponding dimension.

svelte
<script lang="ts">
  import { Skeleton, Text } from '@lostgradient/cinder';
</script>

<Skeleton>
  {#snippet holds()}
    <Text variant="caption">Waiting for the next delivery attempt.</Text>
  {/snippet}
</Skeleton>

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:

svelte
<script lang="ts">
  import { Skeleton } from '@lostgradient/cinder';
</script>

<Skeleton lines={4} />
<Skeleton variant="card" lines={3} />

Table variant

Use variant="table" while a Table with fit loads. Pass the loaded table's column labels in display order, the number of rows to reserve, and selectable when the table has a selection column. The placeholder uses Table's row and cell styles. In a narrow container, the first column's bar becomes the title and the remaining bars appear beside their column labels, including on the first paint.

label names the loading status for assistive technology and defaults to "Loading table".

svelte
<script lang="ts">
  import { Skeleton } from '@lostgradient/cinder';
</script>

<Skeleton
  variant="table"
  columns={[{ label: 'Namespace' }, { label: 'State' }, { label: 'Runs', align: 'end' }]}
  rows={3}
  selectable
  label="Loading namespaces"
/>

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.

svelte
<Skeleton
  variant="form"
  rows={2}
  label="Reading the workflow"
  stillLoadingAfter={10000}
  onCancel={stop}
/>

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 ruled placeholder above the rows for a list grouped by day; a page that knows the day it is about to list passes dayBandLabel="Today, Monday, Nov 2" and dayBandDetail="Central time", and the placeholder draws that text in place of the bar using Cinder’s group label pattern. 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:

svelte
<script lang="ts">
  import { Skeleton } from '@lostgradient/cinder';
</script>

<Skeleton variant="list" rows={3} dayBand label="Loading runs" />

Grouped variant

variant="grouped" is the placeholder for a GroupedList: rows rows (default 3) of two text bars on the same rounded raised surface, with no border and separators that start at the text. Each bar sits in a line box of the text it stands for, so a placeholder row is as tall as a row with a title and a subtitle. action adds a block the height of a small button at the end of each row, for a list whose rows end in text actions; in a row narrower than 26rem, as on a phone, the block drops under the text at its own width, starting at the text's leading edge, where the buttons go. leading adds an icon block in each row's icon slot, with a grouped-list row's metrics (the 28px slot, its 12px gap, the glyph on the title's first line), so the bars start where the text of rows that lead with a glyph starts; trailing adds a short bar at the end of the title's line, standing for a trailing value such as a time, which stays on that line at every width. chevronColumn ends that bar before the row's chevron column, for a list whose rows draw a chevron or keep its column, so the bar ends where the times do. All three are off unless asked for. label and the loading rules work as they do for the list variant:

svelte
<script lang="ts">
  import { Skeleton } from '@lostgradient/cinder';
</script>

<Skeleton variant="grouped" rows={2} action label="Loading reviews" />
<Skeleton
  variant="grouped"
  rows={3}
  leading
  trailing
  chevronColumn
  label="Loading recent activity"
/>

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} and onCancel).
svelte
<script lang="ts">
  import { Skeleton } from '@lostgradient/cinder';

  let loading = $state(true);
</script>

{#if loading}
  <Skeleton lines={5} delay={300} stillLoadingAfter={10000} onCancel={() => (loading = false)} />
{/if}

The status is Skeleton's own line at the top of its placeholder, at the inline start, and never a banner: after a long wait it is the first thing in view, never cut off below a page of placeholders. It takes the place of the first placeholder rather than being inserted above it, so nothing moves when it appears or when the data arrives: in the grouped and list variants it lies over the first row, whose bars give way to it. In a group of bars, a card or a form it lies over the placeholder from its top (inside a card's padding, on its surface) and the bars give way to it, so the group keeps its height. 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. The custom group has zero gap between blocks. Set spacing in the page layout. The group is marked busy and keeps the timing: nothing is drawn until delay, and the status line leads the content, above it. Give the page's first placeholder block holdsStatusLine and the line takes that block's place instead, in a box as tall as the block, so the page does not move when the line appears. Draw each placeholder block with a Skeleton of its own; text in the children is read as written.

svelte
<script lang="ts">
  import { Skeleton } from '@lostgradient/cinder';
</script>

<Skeleton
  delay={300}
  stillLoadingAfter={10000}
  stillLoadingLabel="Still loading Home. This is taking longer than usual."
  onCancel={() => console.log('cancel')}
>
  <div style="display: grid; gap: var(--cinder-space-3)">
    <p>Monday, Nov 2</p>
    <h2>Needs you</h2>
    <Skeleton height="2.5rem" />
  </div>
</Skeleton>

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.

Live preview

Skeleton placeholders

02

When to use

Use when
  • Reserving the rough shape of incoming content during an initial fetch to avoid layout shift.
  • Indicating progressive load of cards, table rows, or media tiles where the final shape is known.
  • Measuring a single bar from hidden, inert content supplied through holds.
  • Composing a custom group through children when the page controls the spacing. The group adds no gap.
Avoid when
  • Indicating indeterminate background work without a known target shape — use spinner.
  • Communicating that a view has no data at all — use empty-state.
03

Examples

Skeleton placeholders

Animated loading placeholders for text and avatars.

Grouped list loading

The grouped variant draws a grouped list's rows on its rounded surface, separators inset at the text. With action, each row keeps a block where its button goes, and on a phone the block drops under the text at its own width.

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 take the first row’s place; it is not a banner.

Loading rules

Nothing for 300 ms, the skeleton until 10 seconds, then Still loading with Cancel.

04

Props

Props for skeleton
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').
holds snippet Content sized under a single bar. The content is hidden and inert, and measures the bar within the available width. Explicit width and height override the measured dimensions.
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''grouped''form''table' '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; 'grouped' draws rows grouped-list rows; 'form' draws rows fields, a label bar over a control bar each; 'table' draws rows rows using Table's wide and stacked layouts.
rows number 3 Number of fields to draw when variant is 'form', of list rows when it is 'list', and of grouped-list rows when it is 'grouped', or of table rows when it is 'table'. A list 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.
columns { label: string; align?: 'start' | 'end' }[] [] Table column labels and alignment, in display order. The first column is the stacked row's title.
selectable boolean false Reserve Table's leading selection column when variant is 'table'.
action boolean false Draw a block the size of a small button at the end of each row when variant is 'grouped', for a grouped list whose rows end in text actions. In a row narrower than 26rem, as on a phone, the block drops under the text at its own width, starting at the text's leading edge, where the real buttons go. Ignored by other variants.
leading boolean false Draw a leading icon block in each row when variant is 'grouped', with a grouped-list row's icon slot metrics (the 28px slot, its 12px gap, and the glyph on the title's first line), so the bars start where the row's text starts, for a list whose rows lead with a glyph. Ignored by other variants.
trailing boolean false Draw a short bar at the inline end of each row's title line when variant is 'grouped', standing for a trailing value such as a time. It is the height of small text and stays on the title's line at every width, unlike action's button block. Ignored by other variants.
chevronColumn boolean false With trailing, end the trailing bar before a grouped-list row's chevron column (the 16px chevron and its gap), so the bar ends where the trailing value of a row that draws a chevron, or keeps its column with GroupedListItem's chevronColumn, ends. Ignored without trailing and 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 false Draw the list's own border and rounded corners when variant is 'list'. A placeholder draws a frame only when the list it stands for does, so the default is none: a status-first list sits flat on its page, and a frame that vanished when the rows arrived would be a jump. Turn it on for a list that draws its own frame. Ignored by other variants.
detailLine boolean false Draw a third bar under each row's two lines when variant is 'list', for a list whose rows carry a detail line (a phone's Schedules rows say why a schedule will not run and what happened last). Without it a row of three lines would load at half as much again as its placeholder. Ignored by other variants.
dayBand boolean false Draw a ruled day heading 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.
dayBandLabel text The text of the day heading when the page knows which day it will list ("Today, Monday, Nov 2"). The placeholder draws it in DataList’s group-label type in place of the bar. Setting it draws the heading without dayBand. Ignored by variants other than 'list'.
dayBandDetail text The text at the end of the day band, such as the zone its times are in ("Central time"). It is drawn only with dayBandLabel.
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. The table variant defaults to 'Loading table'.
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.
holdsStatusLine boolean false For a single block inside a page's own placeholder (the children of a Skeleton with stillLoadingAfter): the group's "Still loading" line takes this block's place when it appears, in a box as tall as the block, instead of being drawn above the page. Mark the first placeholder of the page, so nothing moves when the line appears or when the data arrives. Without a group that shows the line, the block is drawn as usual.
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 leads the content, above it, after stillLoadingAfter, or takes the place of the block marked holdsStatusLine. The group is marked busy while it shows and adds no gap between blocks. Set spacing in the page layout and draw each placeholder block with a Skeleton of its own. Assistive technology reads the content as written.