Skeleton
Reserves the boxes of content that is still loading, so the loaded screen lands in the same place.
import { Inline } from '@slotted/react/inline';import { Skeleton, SkeletonRegion } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';export default function SkeletonBasic() { return ( <SkeletonRegion messages={{ label: 'Loading the dock supervisor' }}> <Inline align="center" gap={4}> <Skeleton shape="circle" size="lg" /> <Stack gap={2}> <Skeleton inlineSize="9rem" /> <Skeleton inlineSize="6rem" /> </Stack> </Inline> </SkeletonRegion> );}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { Skeleton, SkeletonText, SkeletonRegion, SkeletonDefaultsProvider } from '@slotted/react';A placeholder inside a region
Skeleton draws one placeholder. With no props it is a line of text: as wide as its container and as tall as the type around it. SkeletonRegion owns the wait for everything inside it. It carries aria-busy, announces messages.label once through a visually hidden status element, and passes its loading state to every placeholder inside. The placeholders are aria-hidden and inert, so a screen reader hears one message and focus never lands on a bar. This region has no loading prop, so it stays loading; the examples further down switch it.
Shapes
shape states what the placeholder stands for: text is a line of type, block is a box with the height you give it (blockSize), and circle and square are the two boxes an avatar can be. inlineSize and blockSize reserve a width and a height in any CSS length. In React a bare number is pixels.
import { Inline } from '@slotted/react/inline';import { Skeleton } from '@slotted/react/skeleton';export default function SkeletonShapes() { return ( <Inline align="center" gap={5}> <Skeleton inlineSize="6rem" shape="text" /> <Skeleton blockSize="4rem" inlineSize="6rem" shape="block" /> <Skeleton shape="circle" size="lg" /> <Skeleton shape="square" size="lg" /> </Inline> );}Avatar sizes
size applies to circle and square and reads the Avatar scale: xs, sm, md, lg and xl, with md as the default. A placeholder and the Avatar of the same size occupy the same box. text takes its height from the type around it and block takes it from blockSize, so neither reads size.
import { Inline } from '@slotted/react/inline';import { Skeleton } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';const SIZES = ['xs', 'sm', 'md', 'lg', 'xl'] as const;export default function SkeletonSizes() { return ( <Stack gap={4}> <Inline align="center" gap={3}> {SIZES.map((size) => ( <Skeleton key={size} shape="circle" size={size} /> ))} </Inline> <Inline align="center" gap={3}> {SIZES.map((size) => ( <Skeleton key={size} shape="square" size={size} /> ))} </Inline> </Stack> );}Paragraphs
SkeletonText reserves the rows of a paragraph. Each row is one line box of the type it sits in, so three rows occupy the three lines the words will. lines sets the count and defaults to 3. When there is more than one row the last one is drawn short, 62% wide unless lastLineSize says otherwise; a single row is never shortened. inlineSize narrows the whole paragraph.
import { SkeletonText } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';export default function SkeletonTextRows() { return ( <Stack gap={6}> <SkeletonText /> <SkeletonText lastLineSize="40%" lines={5} /> <SkeletonText inlineSize="12rem" lines={1} /> </Stack> );}Type and direction
A placeholder takes its height from the type around it, so one placed inside a Heading is exactly as tall as that heading at its size, with no height written anywhere. Widths and the short last row are logical, so a paragraph under dir="rtl" starts at the right edge.
import { Skeleton, SkeletonText } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';import { Heading } from '@slotted/react/typography';export default function SkeletonContent() { return ( <Stack gap={6}> <Heading level={2} size="2xl"> <Skeleton inlineSize="60%" /> </Heading> <Heading level={2} size="md"> <Skeleton inlineSize="45%" /> </Heading> <div dir="rtl"> <SkeletonText lines={3} /> </div> </Stack> );}Animation
animation chooses how the wait moves: shimmer sends a band across the placeholder and is the default, pulse dims and restores the fill, and none is still. A region passes its value to every placeholder inside it, and a placeholder’s own animation wins. Under prefers-reduced-motion all three stop and the shape stays.
import { SkeletonText } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';const ANIMATIONS = ['shimmer', 'pulse', 'none'] as const;export default function SkeletonAnimation() { return ( <Stack gap={5}> {ANIMATIONS.map((animation) => ( <Stack key={animation} gap={2}> <Text size="sm" tone="muted"> {animation} </Text> <SkeletonText animation={animation} lines={2} /> </Stack> ))} </Stack> );}Covering real content
Put content inside a Skeleton and the box takes that content’s own geometry, hides it, and draws the placeholder over it. When loading ends the box stops taking part in layout and the content stays exactly where it was, so the reserved space cannot differ from what replaces it. Cover one element per box, such as a Text or an Avatar, so that the box and the element are the same size. Here the boxes follow the region: a Skeleton with no loading of its own uses the nearest region’s answer. The button replays a first load of 1.5 seconds.
import { useEffect, useState } from 'react';import { Avatar } from '@slotted/react/avatar';import { Badge } from '@slotted/react/badge';import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { Skeleton, SkeletonRegion } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';export default function SkeletonCover() { const [loading, setLoading] = useState(true); useEffect(() => { if (!loading) return; const timer = setTimeout(() => setLoading(false), 1500); return () => clearTimeout(timer); }, [loading]); return ( <Stack gap={4}> <Inline> <Button onClick={() => setLoading(true)} size="sm" variant="outline"> Replay loading </Button> </Inline> <SkeletonRegion loading={loading} messages={{ label: 'Loading the invoice' }}> <Inline align="center" gap={4}> <Skeleton shape="circle" size="lg"> <Avatar name="Tomás Rivera" size="lg" /> </Skeleton> <Stack gap={1}> <Skeleton> <Text>Tomás Rivera</Text> </Skeleton> <Skeleton> <Text size="sm" tone="muted"> Invoice 4821, due 30 Nov </Text> </Skeleton> </Stack> <Skeleton> <Badge tone="success">Paid in full</Badge> </Skeleton> </Inline> </SkeletonRegion> </Stack> );}Loading a list
A list that is being fetched keeps its chrome painted and reserves only the rows that are coming. The heading and the button render for real. Each row renders the same layout in both states: a circle at the avatar size, and a Skeleton inside each Text, with widths that differ from row to row, so the line height is the one the text will take. loadedLabel makes the region announce a second message when the content arrives; without it the region is silent on arrival. The button replays the first load.
Warehouse team
import { useEffect, useState } from 'react';import { Avatar } from '@slotted/react/avatar';import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { Skeleton, SkeletonRegion } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';import { Heading, Text } from '@slotted/react/typography';const TEAM = [ { name: 'Maria Chen', role: 'Dock supervisor', widths: ['5.5rem', '7rem'] }, { name: 'Tomás Rivera', role: 'Forklift operator', widths: ['6.5rem', '8rem'] }, { name: 'Priya Nair', role: 'Inventory analyst', widths: ['5rem', '7.5rem'] },];export default function SkeletonRegionExample() { const [loading, setLoading] = useState(true); useEffect(() => { if (!loading) return; const timer = setTimeout(() => setLoading(false), 1500); return () => clearTimeout(timer); }, [loading]); return ( <Stack gap={4}> <Inline align="center" gap={3}> <Heading level={2} size="md"> Warehouse team </Heading> <Button onClick={() => setLoading(true)} size="sm" variant="outline"> Replay loading </Button> </Inline> <SkeletonRegion loadedLabel="Team loaded" loading={loading} messages={{ label: 'Loading the team' }} > <Stack gap={4}> {TEAM.map((member) => ( <Inline key={member.name} align="center" gap={3}> {loading ? ( <Skeleton shape="circle" size="md" /> ) : ( <Avatar name={member.name} size="md" /> )} <Stack gap={1}> <Text>{loading ? <Skeleton inlineSize={member.widths[0]} /> : member.name}</Text> <Text size="sm" tone="muted"> {loading ? <Skeleton inlineSize={member.widths[1]} /> : member.role} </Text> </Stack> </Inline> ))} </Stack> </SkeletonRegion> </Stack> );}Loading in pieces
loading on a Skeleton or SkeletonText overrides the region for that box only. Data that arrives in pieces shows each piece as it lands: here the status is known and shown, while the carrier and the notes are still placeholders. With loading={false} in React and [loading]="false" in Angular, the box is no longer aria-hidden or inert.
Shipment SO-10482
import { Badge } from '@slotted/react/badge';import { Inline } from '@slotted/react/inline';import { Skeleton, SkeletonRegion, SkeletonText } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';import { Heading } from '@slotted/react/typography';export default function SkeletonPartial() { return ( <SkeletonRegion messages={{ label: 'Loading shipment SO-10482' }}> <Stack gap={3}> <Heading level={2} size="md"> Shipment SO-10482 </Heading> <Inline align="center" gap={3}> <Skeleton loading={false}> <Badge tone="info">In transit</Badge> </Skeleton> <Skeleton inlineSize="8rem" /> </Inline> <SkeletonText lines={2} /> </Stack> </SkeletonRegion> );}Delay and minimum duration
delay is how long the wait must last before anything is painted, and minDuration is how long a placeholder that did appear stays. Both default to 0. Set them once for the application, 200 and 400 milliseconds being the recommended pair: SkeletonDefaultsProvider in React and provideSkeletonDefaults in Angular. The provider also takes animation, lastLineSize, live and loadedLabel, and a prop on a region or a box still wins. onReveal in React and (reveal) in Angular fire when the placeholders are actually withdrawn, which is later than loading turning false whenever minDuration still holds them. Cover the content, as here, so that it stands during the delay and returns only when the placeholder goes: a page that swaps the two on its own loading follows neither time. The first button responds before the delay, so nothing is drawn and the counter does not move. The second responds 50 ms after the placeholder appears, which stays its 400 ms. The third draws the placeholder after 200 ms and withdraws it with the response.
import { useState } from 'react';import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { Skeleton, SkeletonDefaultsProvider, SkeletonRegion } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';export default function SkeletonTiming() { const [loading, setLoading] = useState(false); const [withdrawn, setWithdrawn] = useState(0); const load = (duration: number) => { setLoading(true); setTimeout(() => setLoading(false), duration); }; return ( <SkeletonDefaultsProvider delay={200} minDuration={400}> <Stack gap={4}> <Inline gap={2}> <Button disabled={loading} onClick={() => load(80)} size="sm" variant="outline"> Respond in 80 ms </Button> <Button disabled={loading} onClick={() => load(250)} size="sm" variant="outline"> Respond in 250 ms </Button> <Button disabled={loading} onClick={() => load(1500)} size="sm" variant="outline"> Respond in 1.5 s </Button> </Inline> <SkeletonRegion loading={loading} messages={{ label: 'Loading the shipment' }} onReveal={() => setWithdrawn((count) => count + 1)} > <Skeleton> <Text>Pallet PL-4821 left dock 6 at 14:05.</Text> </Skeleton> </SkeletonRegion> <Text size="sm" tone="muted"> Placeholders withdrawn: {withdrawn} </Text> </Stack> </SkeletonDefaultsProvider> );}Silent regions
live="off" removes the status element, so the region keeps aria-busy and says nothing. Use it where the surrounding screen already announces the wait, or where the content is decorative, such as a strip of avatars. live defaults to polite.
Recently active
import { useEffect, useState } from 'react';import { Avatar } from '@slotted/react/avatar';import { Button } from '@slotted/react/button';import { Inline } from '@slotted/react/inline';import { Skeleton, SkeletonRegion } from '@slotted/react/skeleton';import { Stack } from '@slotted/react/stack';import { Heading } from '@slotted/react/typography';const ACTIVE = ['Maria Chen', 'Tomás Rivera', 'Priya Nair', 'Jonas Weber'];export default function SkeletonSilent() { const [loading, setLoading] = useState(true); useEffect(() => { if (!loading) return; const timer = setTimeout(() => setLoading(false), 1500); return () => clearTimeout(timer); }, [loading]); return ( <Stack gap={4}> <Inline align="center" gap={3}> <Heading level={2} size="md"> Recently active </Heading> <Button onClick={() => setLoading(true)} size="sm" variant="outline"> Replay loading </Button> </Inline> <SkeletonRegion live="off" loading={loading}> <Inline gap={2}> {ACTIVE.map((name) => loading ? ( <Skeleton key={name} shape="circle" size="md" /> ) : ( <Avatar key={name} name={name} size="md" /> ), )} </Inline> </SkeletonRegion> </Stack> );}Choosing the indicator
A skeleton answers a wait whose structure is known before the data arrives: a list, a table, a card, a form. Other waits take another indicator.
- A control that started the work and stays on screen uses its own
loading, asButtondoes. - Work that reports how much is done uses the progress indicator.
- A region that is already painted and is being replaced uses the loading overlay.
- Refreshing data that is already on screen keeps its values and takes
aria-busyon the region, instead of returning to a skeleton on every refresh.
Two indicators never answer the same wait in the same region. A region that finishes loading with nothing to show renders an empty state, never an empty skeleton, and an error replaces the placeholders.
Accessibility
- Every placeholder carries aria-hidden="true" and inert while it is painted. Reading out the absence of something is noise, and focus must not fall into content that is not ready — a covered button is unreachable rather than reachable and useless.
- An aria-hidden written by hand on a placeholder is kept, so a placeholder that has to stay announced can be.
- The region carries aria-busy="true" while it waits, which is the platform’s own answer: ARIA 1.2 asks an author to set it on the container before the first change and clear it when the last change is complete. The ARIA Authoring Practices Guide has no pattern for a skeleton.
- One region is one announcement. A visually-hidden role="status" holds the label while waiting and is emptied afterwards, and emptying a live region announces nothing, so twelve placeholders do not become twelve messages. loadedLabel opts into a second.
- Under prefers-reduced-motion the loop stops rather than shortening: an infinite animation that hurries is still moving. animation="none", set once through the provider, is the author-side mechanism WCAG 2.2 SC 2.2.2 asks for.
- The placeholder is visible in all three color schemes. The fill is the unavailable surface shifted slightly toward the text color, and a hairline rim takes over in high contrast, where that surface is the page’s own white.
API
Skeleton
Props
shape'text' | 'block' | 'circle' | 'square'Defaulttext- What the placeholder stands for: a line of type, a block of content, a round avatar or a square avatar.
size'xs' | 'sm' | 'md' | 'lg' | 'xl'Defaultmd- The avatar scale, read by the circle and square shapes. Text takes its height from the surrounding type, and block takes it from blockSize or from its content.
inlineSize, blockSizenumber | string- On Skeleton, SkeletonTextThe reserved geometry along the inline and block axes. A bare number is pixels. SkeletonText takes inlineSize only. A box that covers content takes that content’s size unless you state one.
loadingbooleanDefaulttrue- On Skeleton, SkeletonText, SkeletonRegionWhether the content is still on its way. On a box, leaving it unset hands the decision to the nearest region.
linesnumberDefault3- On SkeletonTextHow many rows of the paragraph to reserve.
lastLineSizestringDefault62%- On SkeletonTextThe width of the last row. It applies only when there is more than one row.
animation'shimmer' | 'pulse' | 'none'Defaultshimmer- On Skeleton, SkeletonText, SkeletonRegionHow the wait moves. A region passes its value to every placeholder inside it.
live'polite' | 'off'Defaultpolite- On SkeletonRegionWhether the region announces the wait. The value off leaves the status element out.
messagesPartial<SkeletonMessages>- On SkeletonRegionWords laid over the language in force, key by key. The label key is what a screen reader hears once, while the region waits.
loadedLabelstring- On SkeletonRegionWhat a screen reader hears when the content arrives. The region is silent on arrival unless this is set.
delaynumberDefault0- On SkeletonRegionMilliseconds the wait must last before anything is painted.
minDurationnumberDefault0- On SkeletonRegionMilliseconds a placeholder that did appear stays painted before it is withdrawn.
Events
| Name | Payload | When |
|---|---|---|
onReveal | void | The placeholders are actually withdrawn, which is later than loading turning false whenever minDuration still holds them. Use it to move focus on. |
Composition
childrenReactNode- Covered rather than replaced: the box takes the content’s own geometry, hides it, and reveals it untouched when loading ends.
render(props) => ReactNode- On Skeleton, SkeletonText, SkeletonRegionSubstitutes the rendered element. Every data attribute and the geometry style are passed to it.
refRef<HTMLSpanElement | HTMLDivElement>- On all threeReaches the native element. The props of each part are the props of that element, extended.
SkeletonDefaultsProviderSkeletonDefaults- On ApplicationSets animation, delay, minDuration, loadedLabel, lastLineSize and live once for everything below it. A prop on a region or a box still wins.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | span | Yes | One placeholder box, rendered by Skeleton. Empty it draws the geometry shape and size describe; with children it takes their geometry and covers them. |
text | div | Yes | The rows of a paragraph, rendered by SkeletonText. A grid whose tracks are exactly one line box, so the rows occupy the lines the words will. |
line | span | Yes | One row inside text, repeated lines times. The last of several is drawn short; a lone row is not. |
region | div | Yes | The loading fact for a subtree, rendered by SkeletonRegion. Carries aria-busy, the timing, and the animation phase every placeholder inside it reads. |
announcement | span | Yes | The one visually-hidden role="status" per region. Holds the label while waiting and is emptied afterwards, so a load announces once. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every skeleton inside it.
Skeleton tokens
| Token | Default |
|---|---|
--slotted-skeleton-block-size | var(--_line) |
--slotted-skeleton-border-color | var(--slotted-border-subtle, ButtonBorder) |
--slotted-skeleton-border-width | var(--slotted-border-width-thin, 1px) |
--slotted-skeleton-fill | color-mix( in oklab, var(--slotted-disabled-background, ButtonFace) 92%, var(--slotted-text, CanvasText) ) |
--slotted-skeleton-highlight-color | color-mix(in oklab, var(--_fill) 86%, var(--slotted-text, CanvasText)) |
--slotted-skeleton-inline-size | 100% |
--slotted-skeleton-last-line-size | 62% |
--slotted-skeleton-line-size | 1cap |
--slotted-skeleton-min-block-size | 1lh |
--slotted-skeleton-phase | 0 |
--slotted-skeleton-radius | var(--slotted-radius-md, 6px) |
--slotted-skeleton-row-size | 1lh |
--slotted-skeleton-size | var(--slotted-avatar-size-md, 36px) |
--slotted-skeleton-trough-color | color-mix(in oklab, var(--_fill) 60%, var(--slotted-surface-sunken, Canvas)) |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-avatar-size-lg | comfortable 48px · compact 42px · dense 36px |
--slotted-avatar-size-md | comfortable 36px · compact 32px · dense 28px |
--slotted-avatar-size-sm | comfortable 28px · compact 26px · dense 24px |
--slotted-avatar-size-xl | comfortable 64px · compact 56px · dense 48px |
--slotted-avatar-size-xs | comfortable 24px · compact 22px · dense 20px |
--slotted-border-subtle | Set per scheme by the theme |
--slotted-border-width-thin | 1px |
--slotted-disabled-background | Set per scheme by the theme |
--slotted-duration-loop-slow | 1.6s |
--slotted-radius-full | 9999px |
--slotted-radius-md | 6px |
--slotted-surface-sunken | Set per scheme by the theme |
--slotted-text | Set per scheme by the theme |