Skeleton A placeholder for loading content to provide structural preview before data arrives.
npx vayu-ui init #one time only
npx vayu-ui add -t skeleton #with test case needs
Preview Code
Skeleton Components Loading placeholders with multiple animation styles
Refresh With Root Wrapper (Accessible) 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 >
< Skeleton.Root >
< Skeleton.Item />
< Skeleton.Text />
< Skeleton.Circle />
< Skeleton.Rectangle />
< Skeleton.Card />
< Skeleton.Avatar />
< Skeleton.List />
< Skeleton.Table />
< Skeleton.Grid />
< Skeleton.Group />
</ Skeleton.Root >
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.
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.
Skeleton/
├── index.ts
├── types.ts
├── config.ts
├── SkeletonRoot.tsx
├── SkeletonItem.tsx
├── SkeletonPrimitives.tsx
└── SkeletonComposites.tsx
Prop Type Default Description 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.
Prop Type Default Description 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.
Prop Type Default Description 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.
Prop Type Default Description sizeSkeletonSize'md'Defined size mapping for the circle. animationSkeletonAnimation- Overrides animation style.
Prop Type Default Description 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.
Prop Type Default Description 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.
Prop Type Default Description 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.
Prop Type Default Description itemsnumber3Number of list items to mock. showAvatarbooleantrueIncludes a circle skeleton inside each list item. animationSkeletonAnimation- Overrides animation style. sizeSkeletonSize- Used for internal skeleton dimensions.
Prop Type Default Description rowsnumber5Number of data rows. columnsnumber4Number of table columns. showHeaderbooleantrueRenders a header skeleton row. animationSkeletonAnimation- Overrides animation style. sizeSkeletonSize- Dictates row height sizing.
Prop Type Default Description itemsnumber6Total skeleton blocks. columnsnumber3Columns per row. itemHeightnumber- Internal rectangle height for each grid item. animationSkeletonAnimation- Overrides animation style. sizeSkeletonSize- Drives the spacing format.
Prop Type Default Description spacing'sm' | 'md' | 'lg''md'Provides consistent gaps between skeleton blocks.