Empty State
FreeNewWhat a list or a page shows before it has anything in it: an icon tile, a title, a sentence and up to two actions.
Installation
pnpm dlx shadcn@latest add @viewport/empty-state
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above.
import { Plus, Upload, Users } from "lucide-react";
import { Button } from "@/components/viewport/button";
import { EmptyState } from "@/components/viewport/empty-state";
export default function EmptyStateDemo() {
return (
<EmptyState className="max-w-md bg-card" icon={<Users />} title="No contacts yet" description="Contacts appear here as soon as you add one, import a file or connect your inbox.">
<Button>
<Plus aria-hidden />
Add contact
</Button>
<Button variant="outline">
<Upload aria-hidden />
Import CSV
</Button>
</EmptyState>
);
}Props
| Prop | Type | Default |
|---|---|---|
| icon | React.ReactNodeAn icon that stands for what is missing. Decorative. | — |
| title* | React.ReactNodeWhat is empty, e.g. "No contacts yet". | — |
| description | React.ReactNodeOne or two sentences on why it is empty and what to do next. | — |
| as | "h2" | "h3" | "h4"The heading level, so the state fits the page outline. | — |
| variant | "dashed" | "plain"`dashed` draws a dashed frame, for an empty region inside a page; `plain` has none. | "dashed" |
Accessibility
- A real heading at a level you choose.
- The icon is decorative and hidden from screen readers.
- Server component with no client JavaScript.