---
title: Skeleton for Astro
description: "Astro placeholder shapes that reserve space while content loads."
seo:
    title: Skeleton for Astro | Shadcn & Tailwind CSS
related:
    - /components/spinner
    - /components/empty
    - /components/alert
sidebar:
    label: "Skeleton"
---

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

<div class="flex w-full max-w-sm flex-col gap-2">
  <Skeleton class="h-12 w-12 rounded-full" />
  <Skeleton class="h-4 w-full" />
  <Skeleton class="h-4 w-3/4" />
</div>
```

## Installation

### Command

```sh
bunx --bun shadcn@latest add @gnostic/skeleton
```

### Manual

Complete the [Installation guide](/docs/installation) first. Then copy the component files below.

No extra packages are required.

#### src/components/ui/skeleton/index.ts

```ts
export { default as Skeleton } from "./skeleton.astro"
```

#### src/components/ui/skeleton/skeleton.astro

```astro
---
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div">

const { class: className, ...props } = Astro.props
---

<div data-slot="skeleton" class={cn("animate-skeleton rounded-sm [--skeleton-highlight:--alpha(var(--color-white)/64%)] [background:linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)_var(--color-muted)_0_0/200%_100%_fixed] dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]", className)} {...props}></div>
```

Component classes use the preset configured during project setup. Select the same preset in the docs before copying Manual source. To change installed component classes, edit or reinstall their source. See [Theming](/docs/theming) for details.


## Usage

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

```astro
<Skeleton class="h-4 w-full" />
```

## Example

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

<div class="w-full max-w-sm rounded-lg border p-4">
  <div class="flex items-center gap-3">
    <Skeleton class="size-10 rounded-full" />
    <div class="flex flex-1 flex-col gap-2">
      <Skeleton class="h-4 w-32" />
      <Skeleton class="h-3 w-24" />
    </div>
  </div>
</div>
```

## Notes

- Match the approximate size of the final content to reduce layout shift.
- Use `Skeleton` for loading states, not empty states. For no-data UI, use
  [Empty](/components/empty).

## API Reference

Read the [installed source](/r/skeleton.json) for the complete prop types.

## When to use Skeleton

Use Skeleton to approximate the shape of content that is being fetched. Match the expected image or text area so the page does not shift unnecessarily when real content arrives.

## Keyboard and behavior

Skeleton does not fetch content or manage loading state. Avoid exposing each decorative shape as meaningful content. Put a loading status on the surrounding region when an announcement is needed.

## Theme and layout

The muted surface and pulse follow the shared style. Check reduced motion and enough distinction from the page background. Replace the placeholders with an empty or error state if no content can arrive.
