Empty for Astro
Astro empty-state parts for lists, searches, and unfinished setup.
Installation
bunx --bun shadcn@latest add @gnostic/emptynpx shadcn@latest add @gnostic/emptypnpm dlx shadcn@latest add @gnostic/emptyCopy the files
src/components/ui/empty/empty-content.astrosrc/components/ui/empty/empty-description.astrosrc/components/ui/empty/empty-header.astrosrc/components/ui/empty/empty-media.astrosrc/components/ui/empty/empty-title.astrosrc/components/ui/empty/empty.astrosrc/components/ui/empty/index.ts
Usage
import {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty"
---
import Inbox from "@lucide/astro/icons/inbox"
import { Button } from "@/components/ui/button"
import {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty"
---
<Empty>
<EmptyHeader>
<EmptyMedia variant="icon">
<Inbox />
</EmptyMedia>
<EmptyTitle>No data</EmptyTitle>
<EmptyDescription>No data found.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button>Add data</Button>
</EmptyContent>
</Empty>
Composition
Arrange the parts as shown for an Empty state:
Empty
├── EmptyHeader
│ ├── EmptyMedia
│ ├── EmptyTitle
│ └── EmptyDescription
└── EmptyContent
Examples
Default
Notes
- Use
EmptyHeaderwhen you want the media, title, and description grouped as one block. EmptyMedia variant="icon"is a good default for simple status states.- Add
EmptyContentonly when the empty state needs an action such as retry, clear filters, or go back.
API Reference
Read the installed source for the complete prop types.
When to use Empty
Use Empty where content will appear after an action or data change. Explain why the area is empty and give one useful next step. Add media only when it helps explain the state.
Keyboard and behavior
Empty is static markup. Actions inside it use normal links or buttons. For search results updated by a script, announce the result count through an appropriate live region in your application.
Theme and layout
Spacing and muted text make the message distinct without a heavy surface. Check the action row at narrow widths and avoid fixed heights that create large blank regions.
