Skeleton

updated

A placeholder that holds the place of content while it loads.

Source
Demo

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.

Animations

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

Text

Card

Skeletons compose into the shape of what is loading.

Card

API Reference

class is also accepted and merged over the base classes.

Data attributes

data-slotAttributesDescription
skeletondata-variant, data-animation, data-colorThe placeholder. data-variant is rect, text or circle; data-animation is pulse, wave or none; data-color is the colour, when one is set.

Changelog

  1. registry 0.17.0

    7951a0f — New Marker: an inline status, a bordered row or a labelled separator, from shadcn-vue, with a color. New Banner: a full-width notice with a title, a subtitle, actions and a close button, v-model:open and color. New Tour: parts over Popover for a guided tour driven by useTour. Skeleton takes a color.