Skeleton
Shimmer placeholder for any shape of content — cards, text lines, avatars.
Examples
Card placeholder
Mirror the real layout so content doesn’t jump when it loads.
import { Card, CardContent, CardHeader } from "@codefast/ui/card";
import { Skeleton } from "@codefast/ui/skeleton";
export function SkeletonCard() {
return (
<Card className="w-full max-w-xs">
<CardHeader>
<Skeleton className="h-4 w-2/3" />
<Skeleton className="h-4 w-1/2" />
</CardHeader>
<CardContent>
<Skeleton className="aspect-video w-full" />
</CardContent>
</Card>
);
}
Text lines
Stand in for a paragraph while content loads.
import { Skeleton } from "@codefast/ui/skeleton";
export function SkeletonText() {
return (
<div className="flex w-full max-w-xs flex-col gap-2">
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-3/4" />
</div>
);
}
Avatar
Use to show a placeholder while content is loading.
import { Skeleton } from "@codefast/ui/skeleton";
export function SkeletonAvatar() {
return (
<div className="flex w-fit items-center gap-4">
<Skeleton className="size-10 shrink-0 rounded-full" />
<div className="grid gap-2">
<Skeleton className="h-4 w-37.5" />
<Skeleton className="h-4 w-25" />
</div>
</div>
);
}
Form
Use to show a placeholder while content is loading.
import { Skeleton } from "@codefast/ui/skeleton";
export function SkeletonForm() {
return (
<div className="flex w-full max-w-xs flex-col gap-7">
<div className="flex flex-col gap-3">
<Skeleton className="h-4 w-20" />
<Skeleton className="h-8 w-full" />
</div>
<div className="flex flex-col gap-3">
<Skeleton className="h-4 w-24" />
<Skeleton className="h-8 w-full" />
</div>
<Skeleton className="h-8 w-24" />
</div>
);
}
RTL
Right-to-left layout support for languages such as Arabic and Hebrew.
Translations are AI-generated for demonstration and may be imperfect.
import { Skeleton } from "@codefast/ui/skeleton";
import type { Translations } from "#/features/components-catalog/components/detail/language";
import { useTranslation } from "#/features/components-catalog/components/detail/language-context";
const translations: Translations = {
en: {
dir: "ltr",
values: {},
},
ar: {
dir: "rtl",
values: {},
},
he: {
dir: "rtl",
values: {},
},
};
export function SkeletonRtl() {
const { dir } = useTranslation(translations, "ar");
return (
<div className="flex items-center gap-4" dir={dir}>
<Skeleton className="h-12 w-12 rounded-full" />
<div className="space-y-2">
<Skeleton className="h-4 w-62.5" />
<Skeleton className="h-4 w-50" />
</div>
</div>
);
}
Table
Use to show a placeholder while content is loading.
import { Skeleton } from "@codefast/ui/skeleton";
export function SkeletonTable() {
return (
<div className="flex w-full max-w-sm flex-col gap-2">
{Array.from({ length: 5 }).map((_, index) => (
<div className="flex gap-4" key={index}>
<Skeleton className="h-4 flex-1" />
<Skeleton className="h-4 w-24" />
<Skeleton className="h-4 w-20" />
</div>
))}
</div>
);
}
Usage
The minimal import and composition — see Examples below for styled, real-world variants.
import { Skeleton } from "@codefast/ui/skeleton";
export function SkeletonUsage() {
return <Skeleton className="h-4 w-48" />;
}
Anatomy
How the parts nest — every slot the component exposes, in composition order.
Features
- A single shimmering div — shape it entirely with className (width, height, rounded-full for a circle); no built-in shape presets.
- The shimmer is a moving gradient sweep, not a plain pulse, via the shared animate-shimmer utility.
API reference
Props for each part of the component. All native element props are also forwarded.
Skeleton
A shimmering placeholder block. Shape it entirely with className.
classNamestringSet width, height, and radius to match the content it stands in for.
Accessibility
Built to be keyboard-navigable and screen-reader friendly out of the box.
- Skeletons are decorative — mark the loading region with aria-busy on its container.
- Keep the skeleton’s shape close to the real content to avoid layout shift.
- Don’t leave skeletons up indefinitely; show an error state if loading fails.
Guidelines
Conventions that keep usage consistent across an app.
Do
- Match the skeleton to the final layout’s size and shape.
- Use for content that takes a noticeable moment to load.
Don’t
- Don’t use a skeleton for instant content — it just adds flicker.
- Don’t animate so strongly it distracts; keep the shimmer subtle.
Explore further
Ready to integrate?
Follow the Getting Started guide to install @codefast/ui, or browse the full component gallery.