Skeleton
StableA shimmering gray block that holds the place of content while it loads.
Also known as placeholder, shimmer, loading placeholder, ghost element
Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.
Text lines
<div className="flex w-72 flex-col gap-2">
<Skeleton className="h-3 w-full" />
<Skeleton className="h-3 w-11/12" />
<Skeleton className="h-3 w-2/3" />
</div>Make the lines different lengths so it looks like a paragraph.
When to use it
A gray block with a soft moving shine that holds the space of content still loading. Several together sketch the shape of what is coming, so the page does not jump when it arrives.
Use it for
- Lines of text that are loading: vary the widths.
- A list row with a picture and text, before the data arrives.
- Cards or images whose size you already know.
Not for
- A short wait inside a button: use Spinner.
- The wait before the assistant replies: use TypingIndicator.
- A load that failed: use ErrorState.
Do and avoid
Do
- Match the size and position of the real content, so the page does not jump.
- Vary line lengths so it looks like real text.
- Use a round block for pictures of people and gently rounded blocks for text and images.
- Replace the whole group with real content at once.
- Set a width and height on each block. Without them it has no size and shows nothing.
Avoid
- Do not leave blocks on screen after something fails. Show an error message instead.
- Do not use it inside a button. Use Spinner.
- Do not put text inside a Skeleton. Screen readers cannot see it.
- Do not use a Skeleton and a Spinner for the same area.
On a phone
- Skeleton has no size of its own. It fills the width and height you give it, so use classes that fit a narrow screen.
- The shimmer runs on a phone unless the person has asked for less motion.
Properties
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | none | Sets the size and any radius override. Without a height and width the block collapses to zero. |
| ...rest | HTMLAttributes<HTMLDivElement> | none | Passed to the <div>. |
"Show code under the preview gives the code for the example on the stage."
Tokens
Change one of these and every part that uses it follows.
--surface-sunken--border--animate-shimmer
Built in
- Screen readers skip it.
- The shine stops for people who turn off motion in their system settings.
- It cannot be pressed, and the Tab key skips it.
What you need to do
- Tell screen readers the area is loading, for example with a hidden status message. The blocks themselves are skipped.
Built toward WCAG 2.2 AA and checked automatically; no independent audit yet. Read the accessibility guide