---
title: "Skeleton"
description: "Use to show a placeholder while content is loading."
component: true
---

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

export default function SkeletonDemo() {
  return (
    <div class="flex items-center gap-4">
      <Skeleton class="h-12 w-12 rounded-full" />
      <div class="space-y-2">
        <Skeleton class="h-4 w-[250px]" />
        <Skeleton class="h-4 w-[200px]" />
      </div>
    </div>
  )
}
```

## Installation

<CodeTabs>

<TabsList>
  <TabsTrigger value="cli">Command</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>

<TabsContent value="cli">

```bash
npx solidui-cli@latest add skeleton
```

</TabsContent>

<TabsContent value="manual">

<Steps class="mb-0 pt-2">

<Step>Copy and paste the following code into your project.</Step>

```tsx title="components/ui/skeleton.tsx"
import { type ComponentProps } from "@solidjs/web"

import { cn } from "~/lib/utils"

const Skeleton = (props: ComponentProps<"div">) => (
  <div
    data-slot="skeleton"
    {...props}
    class={cn("rounded-md bg-muted animate-pulse", props.class)}
  />
)

export { Skeleton }
```

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</CodeTabs>

## Usage

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

```tsx
<Skeleton class="h-[20px] w-[100px] rounded-full" />
```

## Avatar

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

export default function SkeletonAvatar() {
  return (
    <div class="flex w-fit items-center gap-4">
      <Skeleton class="size-10 shrink-0 rounded-full" />
      <div class="grid gap-2">
        <Skeleton class="h-4 w-[150px]" />
        <Skeleton class="h-4 w-[100px]" />
      </div>
    </div>
  )
}
```

## Card

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

export default function SkeletonCard() {
  return (
    <Card class="w-full max-w-xs">
      <CardHeader>
        <Skeleton class="h-4 w-2/3" />
        <Skeleton class="h-4 w-1/2" />
      </CardHeader>
      <CardContent>
        <Skeleton class="aspect-video w-full" />
      </CardContent>
    </Card>
  )
}
```

## Text

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

export default function SkeletonText() {
  return (
    <div class="flex w-full max-w-xs flex-col gap-2">
      <Skeleton class="h-4 w-full" />
      <Skeleton class="h-4 w-full" />
      <Skeleton class="h-4 w-3/4" />
    </div>
  )
}
```

## Form

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

export default function SkeletonForm() {
  return (
    <div class="flex w-full max-w-xs flex-col gap-7">
      <div class="flex flex-col gap-3">
        <Skeleton class="h-4 w-20" />
        <Skeleton class="h-8 w-full" />
      </div>
      <div class="flex flex-col gap-3">
        <Skeleton class="h-4 w-24" />
        <Skeleton class="h-8 w-full" />
      </div>
      <Skeleton class="h-8 w-24" />
    </div>
  )
}
```

## Table

```tsx
import { For } from "solid-js"

import { Skeleton } from "~/components/ui/skeleton"

export default function SkeletonTable() {
  return (
    <div class="flex w-full max-w-sm flex-col gap-2">
      <For each={Array.from({ length: 5 })}>
        {() => (
          <div class="flex gap-4">
            <Skeleton class="h-4 flex-1" />
            <Skeleton class="h-4 w-24" />
            <Skeleton class="h-4 w-20" />
          </div>
        )}
      </For>
    </div>
  )
}
```

API Reference
