VayuUI

Skeleton

A placeholder for loading content to provide structural preview before data arrives.

Installation

npx vayu-ui init #one time only
npx vayu-ui add skeleton
npx vayu-ui add -t skeleton #with test case needs

Usage

Skeleton Components

Loading placeholders with multiple animation styles

Text Loading
Avatar Loading
Card Loading
List Loading
Table Loading
Animation Comparison
With Root Wrapper (Accessible)
Loading content
Grid Loading
import { Skeleton } from "@/components/ui/Skeleton";

// Basic Text Skeleton
<Skeleton.Root>
  <Skeleton.Text lines={3} />
</Skeleton.Root>

// Profile Skeleton
<Skeleton.Root animation="wave">
  <Skeleton.Group spacing="md">
    <Skeleton.Avatar showText textLines={2} />
  </Skeleton.Group>
</Skeleton.Root>

// Card Skeleton
<Skeleton.Root>
  <Skeleton.Card showImage lines={4} />
</Skeleton.Root>

// Custom Layout Skeleton
<Skeleton.Root>
  <div className="flex gap-4">
    <Skeleton.Circle size="lg" />
    <div className="flex-1 space-y-2">
      <Skeleton.Rectangle height="1.5rem" width="50%" rounded />
      <Skeleton.Text lines={2} />
    </div>
  </div>
</Skeleton.Root>

Anatomy

<Skeleton.Root>
  <Skeleton.Item />
  <Skeleton.Text />
  <Skeleton.Circle />
  <Skeleton.Rectangle />
  <Skeleton.Card />
  <Skeleton.Avatar />
  <Skeleton.List />
  <Skeleton.Table />
  <Skeleton.Grid />
  <Skeleton.Group />
</Skeleton.Root>

Accessibility

  • Keyboard support: Skeletons are typically decorative and do not require keyboard focus unless they represent interactive elements loading.
  • ARIA attributes: Uses aria-hidden="true" for decorative skeletons to hide them from screen readers. Uses aria-label or aria-labelledby on the root container if the loading state itself is meaningful context.
  • Focus behavior: Non-focusable by default. Focus should remain on the surrounding structural elements or be handled by the layout container representing the loading state.

Screen reader behavior

By default, decorative skeletons (e.g., individual lines of text, shapes) are hidden from screen readers using aria-hidden="true" to prevent noise. A generic loading announcement can be achieved via aria-live or dedicated visibly-hidden loading text on the Skeleton.Root to inform users that content is being fetched.

Component Folder Structure

Skeleton/
├── index.ts
├── types.ts
├── config.ts
├── SkeletonRoot.tsx
├── SkeletonItem.tsx
├── SkeletonPrimitives.tsx
└── SkeletonComposites.tsx

Props

Skeleton.Root

PropTypeDefaultDescription
animationSkeletonAnimation'pulse'The animation style for all child skeletons ('pulse', 'wave', 'none').
sizeSkeletonSize'md'The base size for the skeletons ('sm', 'md', 'lg', 'xl').
aria-labelstring-Accessible label for the skeleton container.
aria-live'polite' | 'assertive' | 'off''polite'Configuration for screen reader live announcements.

Skeleton.Item

PropTypeDefaultDescription
variantSkeletonVariant'rectangular'Shape logic of the skeleton item.
animationSkeletonAnimation-Overrides animation style for the item.
widthstring | number-Explicit width of the item.
heightstring | number-Explicit height of the item.
sizeSkeletonSize-Size scale token.
countnumber1Number of duplicate skeleton items to render.

Skeleton.Text

PropTypeDefaultDescription
linesnumber3Number of text lines to simulate.
widthstring | number'100%'Width of the standard text lines.
lastLineWidthstring | number'60%'Width of the final line.
animationSkeletonAnimation-Overrides animation style.
sizeSkeletonSize-Controls the text height/spacing scale.

Skeleton.Circle

PropTypeDefaultDescription
sizeSkeletonSize'md'Defined size mapping for the circle.
animationSkeletonAnimation-Overrides animation style.

Skeleton.Rectangle

PropTypeDefaultDescription
widthstring | number'100%'Width of the rectangle.
heightstring | number'100%'Height of the rectangle.
roundedbooleantrueApplies border-radius to the rectangle.
animationSkeletonAnimation-Overrides animation style.
sizeSkeletonSize-Base size token.

Skeleton.Card

PropTypeDefaultDescription
showImagebooleantrueIncludes an image placeholder skeleton.
imageHeightnumber-Specific height for the image placeholder placeholder.
linesnumber2Number of text lines below the title.
titleWidthstring | number'60%'Width for the title skeleton block.
animationSkeletonAnimation-Overrides animation style.
sizeSkeletonSize-Base size configuration.

Skeleton.Avatar

PropTypeDefaultDescription
showTextbooleantrueShow adjacent text skeletons.
textLinesnumber2Number of text lines if showing text.
titleWidthstring | number'100px'Width of the primary text line.
subtitleWidthstring | number'150px'Width of the secondary text line.
sizeSkeletonSize'md'Set the circle and text scaling sizes.
animationSkeletonAnimation-Overrides animation style.

Skeleton.List

PropTypeDefaultDescription
itemsnumber3Number of list items to mock.
showAvatarbooleantrueIncludes a circle skeleton inside each list item.
animationSkeletonAnimation-Overrides animation style.
sizeSkeletonSize-Used for internal skeleton dimensions.

Skeleton.Table

PropTypeDefaultDescription
rowsnumber5Number of data rows.
columnsnumber4Number of table columns.
showHeaderbooleantrueRenders a header skeleton row.
animationSkeletonAnimation-Overrides animation style.
sizeSkeletonSize-Dictates row height sizing.

Skeleton.Grid

PropTypeDefaultDescription
itemsnumber6Total skeleton blocks.
columnsnumber3Columns per row.
itemHeightnumber-Internal rectangle height for each grid item.
animationSkeletonAnimation-Overrides animation style.
sizeSkeletonSize-Drives the spacing format.

Skeleton.Group

PropTypeDefaultDescription
spacing'sm' | 'md' | 'lg''md'Provides consistent gaps between skeleton blocks.

On this page