Skeleton for Astro
Astro placeholder shapes that reserve space while content loads.
Installation
bunx --bun shadcn@latest add @gnostic/skeletonnpx shadcn@latest add @gnostic/skeletonpnpm dlx shadcn@latest add @gnostic/skeletonComponent classes: Default Gnostic.
Complete the Installation guide first. Then copy the component files below.
No extra packages are required.
Copy the files
src/components/ui/skeleton/index.ts
export { default as Skeleton } from "./skeleton.astro"
src/components/ui/skeleton/skeleton.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>
Usage
import { Skeleton } from "@/components/ui/skeleton"
<Skeleton class="h-4 w-full" />
Example
Notes
- Match the approximate size of the final content to reduce layout shift.
- Use
Skeletonfor loading states, not empty states. For no-data UI, use Empty.
API Reference
Read the installed source 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.