<!-- index: /slotted/llms.txt -->
# skeleton

`data-ui="skeleton"` · Placeholder shapes while content loads.

## Import

```tsx
import { Skeleton, SkeletonText, SkeletonRegion, SkeletonDefaultsProvider } from '@slotted/react';
```

## Minimal example

Example

```tsx
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>
  );
}
```

## Anatomy

| Part | Element | Required |
| --- | --- | --- |
| `root` | span | yes |
| `text` | div | yes |
| `line` | span | yes |
| `region` | div | yes |
| `announcement` | span | yes |

## Props

| Name | Type | Default | Applies to | Description |
| --- | --- | --- | --- | --- |
| `shape` | `'text' \| 'block' \| 'circle' \| 'square'` | text | Skeleton | 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'` | md | Skeleton | 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, blockSize` | `number \| string` | — | Skeleton, SkeletonText | The 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. |
| `loading` | `boolean` | true | Skeleton, SkeletonText, SkeletonRegion | Whether the content is still on its way. On a box, leaving it unset hands the decision to the nearest region. |
| `lines` | `number` | 3 | SkeletonText | How many rows of the paragraph to reserve. |
| `lastLineSize` | `string` | 62% | SkeletonText | The width of the last row. It applies only when there is more than one row. |
| `animation` | `'shimmer' \| 'pulse' \| 'none'` | shimmer | Skeleton, SkeletonText, SkeletonRegion | How the wait moves. A region passes its value to every placeholder inside it. |
| `live` | `'polite' \| 'off'` | polite | SkeletonRegion | Whether the region announces the wait. The value off leaves the status element out. |
| `messages` | `Partial<SkeletonMessages>` | — | SkeletonRegion | Words laid over the language in force, key by key. The label key is what a screen reader hears once, while the region waits. |
| `loadedLabel` | `string` | — | SkeletonRegion | What a screen reader hears when the content arrives. The region is silent on arrival unless this is set. |
| `delay` | `number` | 0 | SkeletonRegion | Milliseconds the wait must last before anything is painted. |
| `minDuration` | `number` | 0 | SkeletonRegion | Milliseconds a placeholder that did appear stays painted before it is withdrawn. |
| `children` | `ReactNode` | — | Skeleton | Covered rather than replaced: the box takes the content’s own geometry, hides it, and reveals it untouched when loading ends. |
| `render` | `(props) => ReactNode` | — | Skeleton, SkeletonText, SkeletonRegion | Substitutes the rendered element. Every data attribute and the geometry style are passed to it. |
| `ref` | `Ref<HTMLSpanElement \| HTMLDivElement>` | — | all three | Reaches the native element. The props of each part are the props of that element, extended. |
| `SkeletonDefaultsProvider` | `SkeletonDefaults` | — | Application | Sets animation, delay, minDuration, loadedLabel, lastLineSize and live once for everything below it. A prop on a region or a box still wins. |

## 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. |

## Axes and defaults

| Axis | Values | Default |
| --- | --- | --- |
| `shape` | `text`, `block`, `circle`, `square` | `text` |
| `size` | `xs`, `sm`, `md`, `lg`, `xl` | `md` |
| `animation` | `shimmer`, `pulse`, `none` | `shimmer` |
| `live` | `polite`, `off` | `polite` |

## Rules

- 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.

## Tokens

`--slotted-avatar-size-lg`, `--slotted-avatar-size-md`, `--slotted-avatar-size-sm`, `--slotted-avatar-size-xl`, `--slotted-avatar-size-xs`, `--slotted-border-subtle`, `--slotted-border-width-thin`, `--slotted-disabled-background`, `--slotted-duration-loop-slow`, `--slotted-radius-full`, `--slotted-radius-md`, `--slotted-skeleton-block-size`, `--slotted-skeleton-border-color`, `--slotted-skeleton-border-width`, `--slotted-skeleton-fill`, `--slotted-skeleton-highlight-color`, `--slotted-skeleton-inline-size`, `--slotted-skeleton-last-line-size`, `--slotted-skeleton-line-size`, `--slotted-skeleton-min-block-size`, `--slotted-skeleton-phase`, `--slotted-skeleton-radius`, `--slotted-skeleton-row-size`, `--slotted-skeleton-size`, `--slotted-skeleton-trough-color`, `--slotted-surface-sunken`, `--slotted-text`

## Examples

### Playground

A member row, driven by the controls below the canvas. Turn loading off and nothing moves — the placeholders were the real content’s own boxes all along.

Excerpt — not a complete module

```tsx
<Skeleton loading={pending} shape="circle" size="md">
  <Avatar name="Ada Lovelace" size="md" />
</Skeleton>;
```

### What the placeholder stands for

Four relationships to the layout rather than four points on a scale: a line of type, a block of content, and the two boxes an avatar can be.

Example

```tsx
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>
  );
}
```

### A paragraph that has not arrived

The rows are exactly one line box each, so three rows are the three lines the words will take — at any type size, at any density, with no height typed anywhere.

Example

```tsx
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>
  );
}
```

### The round placeholder and the avatar it replaces

size reads the avatar scale, so a placeholder and the picture that lands in its place are the same box at every step and at every density.

Example

```tsx
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>
  );
}
```

### Covering content instead of describing it

Give a placeholder children and it takes their box rather than one you typed, so the reserved space cannot disagree with what replaces it.

Excerpt — not a complete module

```tsx
<Skeleton loading={pending}>
  <Badge tone="success">Paid in full</Badge>
</Skeleton>;
```

### One wait, one announcement

The region carries aria-busy and the single status message; every placeholder inside it is hidden, inert, and reads the region loading state instead of its own.

Example

```tsx
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>
  );
}
```

### The flash, and the flash in reverse

delay withholds the paint until the wait is worth reporting; minDuration holds a placeholder that did appear. Both are zero unless an application sets them.

Example

```tsx
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>
  );
}
```

### How the wait moves

shimmer sends a band across the placeholder and is the default; pulse dims the fill and back for a quieter surface; none is still. Under reduced motion all three stop.

Example

```tsx
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>
  );
}
```

### A loading surface a product would ship

An avatar, a name, a role and a status chip, each placeholder standing in the box its own component will occupy, all under one region that owns the wait.

Excerpt — not a complete module

```tsx
<SkeletonRegion messages={{ label: 'Loading members' }} loading={pending}>
  <Inline gap={5}>
    <Skeleton shape="circle" size="md" />
    <Stack gap={2}>
      <Skeleton inlineSize="9rem" shape="text" />
      <Skeleton inlineSize="5rem" shape="text" />
    </Stack>
  </Inline>
</SkeletonRegion>;
```

### Content the component does not control

A narrow column, a right-to-left paragraph, and a heading whose placeholder is as tall as the heading without being told what a heading is.

Example

```tsx
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>
  );
}
```

### What a reader hears

Every box is hidden and inert; the region says the label once and then falls silent. Tab through the loading half and focus skips it entirely.

Excerpt — not a complete module

```tsx
<SkeletonRegion messages={{ label: 'Loading invoices' }} loadedLabel="Invoices loaded">
  <SkeletonText />
</SkeletonRegion>;

// A region the reader never waits on says nothing at all.
<SkeletonRegion live="off">
  <Skeleton shape="circle" />
</SkeletonRegion>;
```

### cover.tsx

Example

```tsx
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>
  );
}
```

### partial.tsx

Example

```tsx
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>
  );
}
```

### silent.tsx

Example

```tsx
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>
  );
}
```
