Skeleton
updatedA placeholder that holds the place of content while it loads.
Open Props in the corner of the example to try color and animation on the circle. color fills the block with the soft shade of a colour role instead of --accent, and the wave sweeps in that colour; any name declared on [data-slot][data-color] works too.
Installation
Usage
<script setup lang="ts">
import { Skeleton } from '@/components/ui/skeleton'
</script>
<template>
<Skeleton class="h-4 w-48" />
</template>
As in shadcn, a skeleton is a block in --accent with rounded corners that pulses, and you give it its size with classes. It is hidden from screen readers, since it has nothing to say; mark the region that is loading with aria-busy="true" instead, and drop it when the content arrives.
Examples
Animations
animation is pulse by default, the same fade in and out as shadcn's. wave sweeps a band of light across the block, from the start edge to the end edge, so it runs the other way in right-to-left layouts. none keeps it still. With reduced motion, pulse and wave stand still too.
pulse
wave
none
Text
variant="text" stands in for a line of text. It is as tall as the font and sits in the line the way the text would, so give it the text's typescale class and the layout does not move when the text replaces it. variant="circle" is round and square, for avatars: set only its width, or a size-*.
Card
Skeletons compose into the shape of what is loading.
API Reference
class is also accepted and merged over the base classes.
Skeleton
| Prop | Default | Type and description |
|---|---|---|
| variant | — | "rect" | "text" | "circle" | null
|
| animation | — | "pulse" | "wave" | "none" | null
|
| color | — | SkeletonColor | (string & {})Colour role of the fill and the wave. Without it the block is |
Props
- variant
"rect" | "text" | "circle" | nullrect, a block with rounded corners;text, a line as tall as the font;circle, a round square.- animation
"pulse" | "wave" | "none" | nullpulsefades in and out, as in shadcn;wavesweeps a band of light across;nonestays still.- color
SkeletonColor | (string & {})Colour role of the fill and the wave. Without it the block is--accent. Any name declared on[data-slot][data-color]works too.
Data attributes
| data-slot | Attributes | Description |
|---|---|---|
| skeleton | data-variant, data-animation, data-color | The placeholder. data-variant is rect, text or circle; data-animation is pulse, wave or none; data-color is the colour, when one is set. |