$npx @dinachi/cli@latest add skeleton
avatarlinesprofile-loading.tsx
import { Skeleton } from "@/components/ui/skeleton"
export function ProfileLoading() {
return (
<div className="flex items-center space-x-4">
<Skeleton className="h-12 w-12 rounded-full" />
<div className="space-y-2">
<Skeleton className="h-4 w-[250px]" />
<Skeleton className="h-4 w-[200px]" />
</div>
</div>
)
}Usage
import { Skeleton } from "@/components/ui/skeleton"
export function ProfileLoading() {
return <Skeleton className="h-12 w-12 rounded-full" />
}Examples
An avatar and two lines of text.
import { Skeleton } from '@/components/ui/skeleton';
export function Example() {
return (
<div className="flex items-center space-x-4">
<Skeleton className="h-12 w-12 rounded-full" />
<div className="space-y-2">
<Skeleton className="h-4 w-[250px]" />
<Skeleton className="h-4 w-[200px]" />
</div>
</div>
);
}A placeholder for a card with an image.
import { Skeleton } from '@/components/ui/skeleton';
export function Example() {
return (
<div className="flex flex-col space-y-3">
<Skeleton className="h-[125px] w-[250px] rounded-xl" />
<div className="space-y-2">
<Skeleton className="h-4 w-[250px]" />
<Skeleton className="h-4 w-[200px]" />
</div>
</div>
);
}Notes
Match the content
Size each skeleton to the element it replaces so the layout does not jump. Compose several for a card or row.
Avoiding a flash
A fast load flashes the skeleton for one frame. Load Transition delays it and holds it for a minimum time once shown.
API
classNamestring
Sets the size and shape, for example h-4 w-48 or rounded-full.Accessibility
- A plain div with no role; nothing is announced.
- Mark loading with aria-busy on the region the skeletons fill.
animate-pulsekeeps running under reduced motion. Addmotion-reduce:animate-noneto stop it.