Get Started
Components
- Accordion
- Attachment
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Card
- Checkbox
- Code Block
- Collapsible
- Dialog
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Label
- Marker
- Message
- Number Flow
- Pagination
- Popover
- Progress
- Radio Group
- Select
- Slider
- Sonner
- Spinner
- Switch
- Tooltip
- Separator
- Sheet
- Tabs
- Textarea
- Toggle
- Toggle Group
- Trace
AI Elements
Libraries
Utilities
No projects yet
Get started by creating your first project.
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
function Empty({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",
className
)}
data-slot="empty"
{...props}
/>
);
}
function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn("flex max-w-sm flex-col items-center gap-2", className)}
data-slot="empty-header"
{...props}
/>
);
}
const emptyMediaVariants = cva(
"mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
{
defaultVariants: {
variant: "default",
},
variants: {
variant: {
default: "bg-transparent",
icon: "bg-muted text-foreground flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-4",
},
},
}
);
function EmptyMedia({
className,
variant = "default",
...props
}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) {
return (
<div
className={cn(emptyMediaVariants({ className, variant }))}
data-slot="empty-icon"
data-variant={variant}
{...props}
/>
);
}
function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn("text-sm font-medium tracking-tight", className)}
data-slot="empty-title"
{...props}
/>
);
}
function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) {
return (
<div
className={cn(
"text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4",
className
)}
data-slot="empty-description"
{...props}
/>
);
}
function EmptyContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",
className
)}
data-slot="empty-content"
{...props}
/>
);
}
export {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
};Empty is a composable placeholder for zero-data screens — inbox, search results, project lists, first-run onboarding. It renders a dashed surface with a stacked icon, title, description, and optional call-to-action.
Installation
$ bunx --bun frakment add empty$ npx frakment add empty$ pnpm dlx frakment add empty$ yarn dlx frakment add empty
Install the following dependencies:
$ bun add class-variance-authority$ npm install class-variance-authority$ pnpm add class-variance-authority$ yarn add class-variance-authority
Copy and paste the following code into your project.
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
function Empty({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",
className
)}
data-slot="empty"
{...props}
/>
);
}
function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn("flex max-w-sm flex-col items-center gap-2", className)}
data-slot="empty-header"
{...props}
/>
);
}
const emptyMediaVariants = cva(
"mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
{
defaultVariants: {
variant: "default",
},
variants: {
variant: {
default: "bg-transparent",
icon: "bg-muted text-foreground flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-4",
},
},
}
);
function EmptyMedia({
className,
variant = "default",
...props
}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) {
return (
<div
className={cn(emptyMediaVariants({ className, variant }))}
data-slot="empty-icon"
data-variant={variant}
{...props}
/>
);
}
function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn("text-sm font-medium tracking-tight", className)}
data-slot="empty-title"
{...props}
/>
);
}
function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) {
return (
<div
className={cn(
"text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4",
className
)}
data-slot="empty-description"
{...props}
/>
);
}
function EmptyContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn(
"flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",
className
)}
data-slot="empty-content"
{...props}
/>
);
}
export {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
};Update the import paths to match your project setup.
Composition
Empty
├── EmptyHeader
├── EmptyMedia
├── EmptyTitle
├── EmptyDescription
└── EmptyContentExamples
Without media
Omit EmptyMedia entirely for the simplest empty state.
No results found
Try adjusting your search or filters.
"use client";
import {
Empty,
EmptyDescription,
EmptyHeader,
EmptyTitle,
} from "@/components/ui/empty";
export function EmptyNoMedia() {
return (
<Empty className="max-w-sm border">
<EmptyHeader>
<EmptyTitle>No results found</EmptyTitle>
<EmptyDescription>
Try adjusting your search or filters.
</EmptyDescription>
</EmptyHeader>
</Empty>
);
}<Empty>
<EmptyHeader>
<EmptyTitle>No results found</EmptyTitle>
<EmptyDescription>Try adjusting your search or filters.</EmptyDescription>
</EmptyHeader>
</Empty>With description link
EmptyDescription accepts inline links that pick up Frakment underline styling.
No projects yet
Read the guide to learn how to create one.
"use client";
import { Folder } from "lucide-react";
import {
Empty,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty";
export function EmptyLink() {
return (
<Empty className="max-w-sm border">
<EmptyHeader>
<EmptyMedia variant="icon">
<Folder />
</EmptyMedia>
<EmptyTitle>No projects yet</EmptyTitle>
<EmptyDescription>
<a href="#docs">Read the guide</a> to learn how to create one.
</EmptyDescription>
</EmptyHeader>
</Empty>
);
}<Empty>
<EmptyHeader>
<EmptyMedia variant="icon">
<Folder />
</EmptyMedia>
<EmptyTitle>No projects yet</EmptyTitle>
<EmptyDescription>
<a href="#docs">Read the guide</a> to learn how to create one.
</EmptyDescription>
</EmptyHeader>
</Empty>Outline media
Use variant="default" on EmptyMedia to render media without a muted background square.
Nothing here
Use variant="default" to render media without a background.
"use client";
import { Folder } from "lucide-react";
import {
Empty,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty";
export function EmptyOutline() {
return (
<Empty className="max-w-sm border">
<EmptyHeader>
<EmptyMedia>
<Folder />
</EmptyMedia>
<EmptyTitle>Nothing here</EmptyTitle>
<EmptyDescription>
Use variant="default" to render media without a background.
</EmptyDescription>
</EmptyHeader>
</Empty>
);
}<Empty>
<EmptyHeader>
<EmptyMedia>
<Folder />
</EmptyMedia>
<EmptyTitle>Nothing here</EmptyTitle>
<EmptyDescription>
Use variant="default" to render media without a background.
</EmptyDescription>
</EmptyHeader>
</Empty>In Context
Zero-data state
No messages
Start a new conversation to see it here.
"use client";
import { MessageCircleDashedIcon } from "lucide-react";
import {
Empty,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty";
export function EmptyZeroData() {
return (
<Empty className="mx-auto h-64 w-full max-w-sm">
<EmptyHeader>
<EmptyMedia>
<MessageCircleDashedIcon />
</EmptyMedia>
<EmptyTitle>No messages</EmptyTitle>
<EmptyDescription>
Start a new conversation to see it here.
</EmptyDescription>
</EmptyHeader>
</Empty>
);
}API Reference
All parts extend React.ComponentProps<"div"> (except EmptyDescription which renders a <div> too for layout consistency).
EmptyMedia
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default""icon" | — | Icon wraps the child in a rounded muted square; default is transparent. |
Usage
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty";
<DocsBaseSwitcher base="web" component="empty" className="mb-6" /><Empty>
<EmptyHeader>
<EmptyMedia><MessageCircleDashedIcon /></EmptyMedia>
<EmptyTitle>No messages yet</EmptyTitle>
<EmptyDescription>Send the first one.</EmptyDescription>
</EmptyHeader>
</Empty>Accessibility
- The
EmptyTitlerenders as a heading; document outline stays flat. - Pair the icon with the title; icon-only empty states are invisible to screen readers.
- Provide a primary action inside the empty state when possible.
Best Practices
- Explain the empty state. "No messages" beats "Empty".
- Offer the first action. A button or link beats a dead end.
- Keep it small. Empty states should not fill the whole page unless the page is empty.
- Do not hide the empty state during loading. Use a Skeleton instead.