default.tsx
1'use client';23import { Skeleton } from '@/components/ui/skeleton';45const lines = [{ className: 'h-4 w-[200px]' }, { className: 'h-4 w-[160px]' }];67export function Default() {8 return (9 <div className="flex items-center gap-4">10 <Skeleton className="h-12 w-12 rounded-full" />11 <div className="space-y-2">12 {lines.map((line, i) => (13 <Skeleton key={i} className={line.className} />14 ))}15 </div>16 </div>17 );18}
Installation
pnpm dlx nachui add skeletonAnatomy
1import { Skeleton } from '@/components/ui/skeleton';
1<Skeleton className="h-4 w-[200px]" />
Examples
Default
default.tsx
1'use client';23import { Skeleton } from '@/components/ui/skeleton';45const lines = [{ className: 'h-4 w-[200px]' }, { className: 'h-4 w-[160px]' }];67export function Default() {8 return (9 <div className="flex items-center gap-4">10 <Skeleton className="h-12 w-12 rounded-full" />11 <div className="space-y-2">12 {lines.map((line, i) => (13 <Skeleton key={i} className={line.className} />14 ))}15 </div>16 </div>17 );18}
Card
A full card loading state skeleton.
card.tsx
1'use client';23import { Skeleton } from '@/components/ui/skeleton';45const lines = [{ className: 'h-5 w-3/4' }, { className: 'h-4 w-full' }, { className: 'h-4 w-5/6' }];67const actions = [{ className: 'h-9 w-24 rounded-md' }, { className: 'h-9 w-24 rounded-md' }];89export function Card() {10 return (11 <div className="border-border w-full max-w-sm space-y-4 rounded-xl border p-6">12 <Skeleton className="h-[140px] w-full rounded-lg" />13 <div className="space-y-2">14 {lines.map((line, i) => (15 <Skeleton key={i} className={line.className} />16 ))}17 </div>18 <div className="flex gap-2 pt-2">19 {actions.map((action, i) => (20 <Skeleton key={i} className={action.className} />21 ))}22 </div>23 </div>24 );25}
API Reference
Skeleton
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Additional CSS classes — use to set width, height, and border-radius. |
Found something to improve?
Notice a bug, typo, or missing detail on this page? Help us make the documentation better by opening a GitHub issue.