# Skeleton

A placeholder pencilled in with hatching the pen keeps going back over.

Docs: https://ballpoint.st9wd.com/docs/skeleton

```bash
npx shadcn@latest add @ballpoint/skeleton
```

```tsx
import { Skeleton } from "@/components/ui/skeleton"

<Skeleton className="h-4 w-48" />
```

Props:

- `className`: `string`. Size and shape it: rounded-full makes a round placeholder.
- `SkeletonText lines`: `number` (default `3`). A paragraph of placeholder: this many lines, the last one shorter, each a different width.
- `seed`: `string | number`. Pins the hatching.

## Example

```tsx
import { Skeleton } from "@/components/ui/skeleton";

export default function SkeletonDemo() {
  return (
    <div className="flex items-center gap-4">
      <Skeleton className="size-12 rounded-full" seed="sk-avatar" />
      <div className="flex flex-col gap-2">
        <Skeleton className="h-4 w-56" seed="sk-line-1" />
        <Skeleton className="h-4 w-40" seed="sk-line-2" />
      </div>
    </div>
  );
}
```

## Card placeholder

The shape of a card while its content loads.

```tsx
import { Card, CardContent, CardHeader } from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";

export default function SkeletonCard() {
  return (
    <Card className="w-full max-w-sm" seed="sc-card">
      <CardHeader>
        <Skeleton className="h-5 w-40" seed="sc-title" />
        <Skeleton className="h-4 w-56" seed="sc-sub" />
      </CardHeader>
      <CardContent className="flex flex-col gap-3">
        <Skeleton className="h-32 w-full" seed="sc-image" />
        <Skeleton className="h-4 w-full" seed="sc-l1" />
        <Skeleton className="h-4 w-2/3" seed="sc-l2" />
      </CardContent>
    </Card>
  );
}
```

## Text

A heading and paragraphs of placeholder lines, each a different length.

```tsx
import { Skeleton, SkeletonText } from "@/components/ui/skeleton";

export default function SkeletonTextExample() {
  return (
    <article className="flex w-full max-w-md flex-col gap-4">
      <Skeleton className="h-7 w-2/3" seed="st-title" />
      <SkeletonText lines={4} seed="st-body" />
      <SkeletonText lines={2} seed="st-more" />
    </article>
  );
}
```

## A list

Round avatars with a name and two lines of text, three times over.

```tsx
import { Skeleton, SkeletonText } from "@/components/ui/skeleton";

export default function SkeletonProfile() {
  return (
    <ul className="flex w-full max-w-md flex-col gap-6">
      {[0, 1, 2].map((i) => (
        <li key={i} className="flex items-start gap-4">
          <Skeleton className="size-12 shrink-0 rounded-full" seed={`sp-avatar-${i}`} />
          <div className="flex flex-1 flex-col gap-3">
            <Skeleton className="h-5 w-1/3" seed={`sp-name-${i}`} />
            <SkeletonText lines={2} seed={`sp-text-${i}`} />
          </div>
        </li>
      ))}
    </ul>
  );
}
```
