Display
Skeleton
Pulsing bg-2 block that holds the place of content while it loads. Match the shape of what will appear.
import { Skeleton } from '@statix/ui/skeleton';Examples
Basic
Size it with width and height classes.
<script lang="ts">
import { Skeleton } from '@statix/ui/skeleton';
</script>
<div class="flex items-center gap-4">
<Skeleton class="size-14 rounded-full" />
<div class="flex flex-col gap-2">
<Skeleton class="h-4 w-48" />
<Skeleton class="h-4 w-32" />
</div>
</div>Dashboard card
A placeholder with the same layout as the loaded card, so nothing jumps.
<script lang="ts">
import * as Card from '@statix/ui/card';
import { Skeleton } from '@statix/ui/skeleton';
</script>
<Card.Root class="w-full max-w-md" aria-busy="true" aria-label="Loading websites">
<Card.Header class="grid-cols-[auto_1fr] gap-x-5">
<Skeleton class="row-span-2 size-12 rounded-full" />
<Skeleton class="h-6 w-32" />
<Skeleton class="h-4 w-48" />
</Card.Header>
<Card.Content class="gap-2">
<Skeleton class="h-4 w-full" />
<Skeleton class="h-4 w-2/3" />
</Card.Content>
<Card.Footer>
<Skeleton class="h-4 w-40" />
</Card.Footer>
</Card.Root>Table rows
Rows of bars at the table’s row height while invoices load.
Loading invoices
<script lang="ts">
import { Skeleton } from '@statix/ui/skeleton';
</script>
<div class="w-full max-w-xl divide-y divide-border" aria-busy="true">
<span class="sr-only">Loading invoices</span>
{#each [1, 2, 3] as row (row)}
<div class="flex h-14 items-center gap-6">
<Skeleton class="h-4 w-28" />
<Skeleton class="h-4 w-20" />
<Skeleton class="ml-auto h-4 w-16" />
<Skeleton class="h-6 w-14 rounded-full" />
</div>
{/each}
</div>Guidelines
Do
- Copy the layout of the real content: same heights, gaps and radii.
- Use rounded-full for avatars and pills, the default 10px radius for text lines.
Don't
- Don’t show skeletons for less than about 300ms. Delay them so fast loads don’t flicker.
- Don’t use skeletons for actions the customer started. Use a spinner in the button instead.
Accessibility
- Skeleton is aria-hidden. Mark the loading region with aria-busy="true" and give it a label, or add an sr-only "Loading invoices" text.
- The pulse stops when the user prefers reduced motion.
API reference
Skeleton
renders<div aria-hidden="true"> and accepts its attributes| Prop | Type | Default |
|---|---|---|
ref bind | HTMLDivElement | null The rendered element. | – |
class | ClassValue Size and shape. Merged with the base classes; yours win. | – |
| Data attribute | Meaning |
|---|---|
data-slot="skeleton" | Always present. |