Skeleton
Loading placeholder components that mimic content shapes with a pulse animation.
Basic
Loading placeholders that mimic the shape of content before it loads. Supports text lines, circles, and rectangles with a gentle pulse animation.
Installation
Install the component via the CLI in one command.
npx @work-rjkashyap/unified-ui add skeletonpnpm dlx @work-rjkashyap/unified-ui add skeletonnpx @work-rjkashyap/unified-ui add skeletonbunx @work-rjkashyap/unified-ui add skeletonIf you haven't initialized your project yet, run npx @work-rjkashyap/unified-ui init first. See the CLI docs for details.
Or install the full package
Use this approach if you prefer to install the entire design system as a dependency instead of copying individual components.
npm install @work-rjkashyap/unified-uipnpm add @work-rjkashyap/unified-uiyarn add @work-rjkashyap/unified-uibun add @work-rjkashyap/unified-uiAnatomy
import {
Skeleton,
SkeletonText,
SkeletonCircle,
SkeletonRect,
} from "@work-rjkashyap/unified-ui";Basic Skeleton
The base Skeleton component renders a single animated placeholder. Use the shape prop to control its form.
<Skeleton shape="text" />
<Skeleton shape="circle" size="md" />
<Skeleton shape="rect" width={200} height={120} />SkeletonText
Renders one or more text-line placeholders. Use the lines prop to control the number of lines. The last line is automatically shorter for a natural appearance.
1 line
3 lines
5 lines
Text Sizes
Two sizes control the height of each text line to match your typography scale.
Small
Medium (default)
SkeletonCircle
Renders a circular placeholder. Perfect for avatar and icon loading states.
| Size | Dimensions | Matches |
|---|---|---|
xs | 24×24px | Avatar xs |
sm | 32×32px | Avatar sm |
md | 40×40px | Avatar md |
lg | 48×48px | Avatar lg |
xl | 64×64px | Avatar xl |
SkeletonRect
Renders a rectangular placeholder with configurable width and height. Useful for images, cards, and media content loading states.
Composition Examples
User Card Skeleton
A common loading pattern for user profile cards.
Article Skeleton
A loading placeholder for article or blog post content.
Table Row Skeleton
Loading state for data table rows.
Custom Dimensions
Both width and height accept numbers (pixels) or strings (CSS values like percentages or auto).
// Pixel values
<SkeletonRect width={300} height={200} />
// CSS string values
<SkeletonRect width="100%" height={120} />
<SkeletonRect width="50%" height="8rem" />
// Full width text
<SkeletonText lines={2} className="w-full" />Props
Skeleton
| Prop | Type | Default | Description |
|---|---|---|---|
shape | "text" | "circle" | "rect" | "text" | Shape of the skeleton placeholder. |
size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | Size preset (used with circle shape). |
width | number | string | — | Custom width. Numbers are treated as pixels. |
height | number | string | — | Custom height. Numbers are treated as pixels. |
className | string | — | Additional CSS classes. |
SkeletonText
| Prop | Type | Default | Description |
|---|---|---|---|
lines | number | 3 | Number of text lines to render. |
size | "sm" | "md" | "md" | Height of each text line. |
className | string | — | Additional CSS classes. |
SkeletonCircle
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | Diameter of the circle. |
className | string | — | Additional CSS classes. |
SkeletonRect
| Prop | Type | Default | Description |
|---|---|---|---|
width | number | string | "100%" | Width of the rectangle. |
height | number | string | 80 | Height of the rectangle. |
className | string | — | Additional CSS classes. |
Accessibility
Skeleton placeholders are purely decorative and should not convey meaningful information.
- All skeleton elements render with
aria-hidden="true"so screen readers skip them. - The root element uses
role="presentation"to indicate decorative content. - The pulse animation automatically respects
prefers-reduced-motion— when the user prefers reduced motion, the animation is disabled via the global CSS rule instyles.css. - When using skeletons as loading states, ensure the surrounding container or page communicates the loading state to assistive technology (e.g., via
aria-busy="true"on the parent, or a visually hidden "Loading..." text).
Reduced Motion
The skeleton pulse animation is defined via animate-pulse in Tailwind, which is automatically disabled when the user has prefers-reduced-motion: reduce enabled. No additional configuration is needed.
/* Handled globally in styles.css */
@media (prefers-reduced-motion: reduce) {
.animate-pulse {
animation: none;
}
}Design Tokens
| Token | Usage |
|---|---|
--muted | Skeleton placeholder background |
--radius-sm | Text line and rect border radius |
--radius-full | Circle shape border radius |