A placeholder shape that holds the layout while content loads.
pnpm dlx shadcn@latest add @latheui/skeletonFirst time? Run npx latheui init once to add the @latheui registry. The CLI then writes the source into your project and installs what it needs. Or add it by hand:
Copy the source into your project.
import * as React from "react"
import { cn } from "@/lib/utils"
/**
* A placeholder block. Size it with classes to match the content it stands
* in for, and put `aria-busy` on the region that is loading.
*/
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="skeleton"
aria-hidden="true"
className={cn("animate-pulse rounded-md bg-muted motion-reduce:animate-none", className)}
{...props}
/>
)
}
export { Skeleton }Accepts every native div attribute. Size and shape come from className.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Width, height and radius of the placeholder. |
<div className="flex flex-col gap-2">
<Skeleton className="h-3.5 w-full" />
<Skeleton className="h-3.5 w-11/12" />
<Skeleton className="h-3.5 w-2/3" />
</div>