Empty
Display additional information or actions to an input or textarea.
Made by shadcnPowered by
Installation
When to use
Use this decision tree to determine when to use the Empty component:
Usage
import {
Empty,
EmptyContent,
EmptyDescription,
EmptyHeader,
EmptyMedia,
EmptyTitle,
} from "@/components/ui/empty"<Empty>
<EmptyHeader>
<EmptyMedia variant="icon">
<Icon />
</EmptyMedia>
<EmptyTitle>No data</EmptyTitle>
<EmptyDescription>No data found</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button>Add data</Button>
</EmptyContent>
</Empty>Anatomy
The Empty component is structured as a centered layout designed to communicate the absence of content. Here's how the components work together:
<Empty> {/* Container with centered flex layout */}
<EmptyHeader> {/* Groups media, title, and description */}
<EmptyMedia> {/* Optional visual (icon, avatar, image) */}
<EmptyTitle> {/* Primary message */}
<EmptyDescription> {/* Supporting details */}
</EmptyHeader>
<EmptyContent> {/* Optional actions (buttons, links, inputs) */}
</Empty>Layout Structure
- Empty: Root container that centers content vertically and horizontally
- EmptyHeader: Stacks media, title, and description in a column with consistent spacing
- EmptyMedia: Displays visual elements (icons with
variant="icon", or custom content like avatars) - EmptyTitle: Primary heading styled for prominence
- EmptyDescription: Secondary text providing context or instructions
- EmptyContent: Action area for buttons, forms, or links
Typical Usage Pattern
// Minimal empty state
<Empty>
<EmptyHeader>
<EmptyTitle>No results found</EmptyTitle>
<EmptyDescription>Try adjusting your search.</EmptyDescription>
</EmptyHeader>
</Empty>
// Full empty state with icon and action
<Empty>
<EmptyHeader>
<EmptyMedia variant="icon">
<SearchIcon />
</EmptyMedia>
<EmptyTitle>No projects yet</EmptyTitle>
<EmptyDescription>Get started by creating your first project.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button>Create Project</Button>
</EmptyContent>
</Empty>Examples
Outline
Use the border utility class to create a outline empty state.
Background
Use the bg-* and bg-gradient-* utilities to add a background to the empty state.
Avatar
Use the EmptyMedia component to display an avatar in the empty state.
Avatar Group
Use the EmptyMedia component to display an avatar group in the empty state.
InputGroup
You can add an InputGroup component to the EmptyContent component.
API Reference
Empty
The main component of the empty state. Wraps the EmptyHeader and EmptyContent components.
| Prop | Type | Default |
|---|---|---|
className | string |
<Empty>
<EmptyHeader />
<EmptyContent />
</Empty>EmptyHeader
The EmptyHeader component wraps the empty media, title, and description.
| Prop | Type | Default |
|---|---|---|
className | string |
<EmptyHeader>
<EmptyMedia />
<EmptyTitle />
<EmptyDescription />
</EmptyHeader>EmptyMedia
Use the EmptyMedia component to display the media of the empty state such as an icon or an image. You can also use it to display other components such as an avatar.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "icon" | default |
className | string |
<EmptyMedia variant="icon">
<Icon />
</EmptyMedia><EmptyMedia>
<Avatar>
<AvatarImage src="..." />
<AvatarFallback>CN</AvatarFallback>
</Avatar>
</EmptyMedia>EmptyTitle
Use the EmptyTitle component to display the title of the empty state.
| Prop | Type | Default |
|---|---|---|
className | string |
<EmptyTitle>No data</EmptyTitle>EmptyDescription
Use the EmptyDescription component to display the description of the empty state.
| Prop | Type | Default |
|---|---|---|
className | string |
<EmptyDescription>You do not have any notifications.</EmptyDescription>EmptyContent
Use the EmptyContent component to display the content of the empty state such as a button, input or a link.
| Prop | Type | Default |
|---|---|---|
className | string |
<EmptyContent>
<Button>Add Project</Button>
</EmptyContent>Props
Credits
- We take our inspiration from Shadcn UI for the
emptycomponent and style.
Built by malinskibeniamin. The source code is available on GitHub.