Search every page in the navigation.
Use to show a placeholder while content is loading.
import { Skeleton } from "@/components/ui/skeleton"
function SkeletonDemo() {
return (
<div className="flex items-center gap-3">
<Skeleton className="size-8 shrink-0 rounded-full" />
<div className="flex flex-col">
<div className="flex h-[1lh] items-center text-label-14">
<Skeleton className="h-[0.75em] w-32" />
</div>
<div className="flex h-[1lh] items-center text-label-13">
<Skeleton className="h-[0.75em] w-20" />
</div>
</div>
</div>
)
}
export default SkeletonDemonpx shadcn@latest add @ziiz/skeletonimport { Skeleton } from "@/components/ui/skeleton"<Skeleton className="h-[20px] w-[100px] rounded-full" />A bar that stands in for text takes the text's measurements from its type role. Give the container the role, make each line one line box, h-[1lh], and set the bar to cap height, h-[0.75em]. The skeleton is then exactly as tall as the text it replaces, in any role, and nothing moves when the text lands.
<div className="text-copy-14">
<div className="flex h-[1lh] items-center">
<Skeleton className="h-[0.75em] w-full" />
</div>
</div>import { Skeleton } from "@/components/ui/skeleton"
function SkeletonAvatar() {
return (
<div className="flex items-center gap-4">
<Skeleton className="size-6 rounded-full" />
<Skeleton className="size-8 rounded-full" />
<Skeleton className="size-10 rounded-full" />
</div>
)
}
export default SkeletonAvatarimport {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import { Skeleton } from "@/components/ui/skeleton"
function SkeletonCard() {
return (
<Card className="w-full max-w-xs">
<CardHeader>
<CardTitle className="flex h-[1lh] items-center">
<Skeleton className="h-[0.75em] w-2/3" />
</CardTitle>
<CardDescription className="flex h-[1lh] items-center">
<Skeleton className="h-[0.75em] w-1/2" />
</CardDescription>
</CardHeader>
<CardContent>
<Skeleton className="aspect-video w-full" />
</CardContent>
</Card>
)
}
export default SkeletonCardimport { Skeleton } from "@/components/ui/skeleton"
import { cn } from "@/lib/utils"
function SkeletonText() {
return (
<div className="w-full max-w-xs text-copy-14">
{["w-full", "w-full", "w-3/4"].map((width, index) => (
<div key={index} className="flex h-[1lh] items-center">
<Skeleton className={cn("h-[0.75em]", width)} />
</div>
))}
</div>
)
}
export default SkeletonTextimport { Skeleton } from "@/components/ui/skeleton"
function SkeletonForm() {
return (
<div className="flex w-full max-w-xs flex-col gap-7">
{["w-20", "w-24"].map((width, index) => (
<div key={index} className="flex flex-col gap-3">
<div className="flex h-[1lh] items-center text-label-14">
<Skeleton className={`h-[0.75em] ${width}`} />
</div>
<Skeleton className="h-9 w-full" />
</div>
))}
<Skeleton className="h-9 w-20" />
</div>
)
}
export default SkeletonFormimport { Skeleton } from "@/components/ui/skeleton"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
import { cn } from "@/lib/utils"
const rows = [
["w-24", "w-16", "w-12"],
["w-20", "w-16", "w-14"],
["w-28", "w-16", "w-12"],
["w-24", "w-16", "w-10"],
]
function Line({ className }: { className: string }) {
return (
<div className="flex h-[1lh] items-center">
<Skeleton className={cn("h-[0.75em]", className)} />
</div>
)
}
function SkeletonTable() {
return (
<div className="w-full max-w-sm">
<Table>
<TableHeader>
<TableRow>
<TableHead>
<Line className="w-16" />
</TableHead>
<TableHead>
<Line className="w-12" />
</TableHead>
<TableHead>
<Line className="w-14" />
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{rows.map((cells, index) => (
<TableRow key={index}>
{cells.map((width, cell) => (
<TableCell key={cell}>
<Line className={width} />
</TableCell>
))}
</TableRow>
))}
</TableBody>
</Table>
</div>
)
}
export default SkeletonTable