| title | Skeleton |
|---|---|
| description | A placeholder loading state that mimics the layout of content while it's being loaded. |
| source | packages/raystack/components/skeleton |
import { playground, basicDemo, multipleDemo, customStylesDemo, animationDemo, cardDemo, providerDemo, } from "./demo.ts";
Import and assemble the component:
import { Skeleton } from "@raystack/apsara";
<Skeleton />Renders a placeholder loading animation that mimics content layout.
A simple skeleton loader with fixed dimensions.
Create multiple skeleton lines using the count prop.
Group multiple skeletons and share common props using Skeleton.Provider.
Customize the appearance using baseColor and highlightColor.
Control the animation duration or disable it entirely.
Create a card-like loading state by combining multiple skeletons.
The Skeleton component supports a Provider pattern that allows you to share common props across multiple skeleton instances:
<Skeleton.Provider
baseColor="var(--rs-color-background-base-secondary)"
height="24px"
duration={2}
>
<Skeleton /> {/* Inherits provider props */}
<Skeleton width="75%" /> {/* Inherits provider props, overrides width */}
<Skeleton
height="48px"
borderRadius="50%"
/> {/* Overrides specific props */}
</Skeleton.Provider>All props available on the Skeleton component can be passed to the Provider and will be inherited by child Skeleton components. Individual Skeleton components can override any provider props with their own values.
The Skeleton component follows accessibility best practices:
- Uses semantic HTML elements
- Provides appropriate ARIA attributes
- Maintains sufficient color contrast
- Respects motion preferences: skeleton shimmer is enabled only when
prefers-reduced-motion: no-preference - Supports both block and inline layouts