Empty
newAn empty state with media, a title, a description and actions, sized by one prop and drawn on whatever holds it.
Open Props in the corner of the example to try size.
sm, md and lg in cards of one size, so only the empty state changes.
Installation
Usage
<script setup lang="ts">
import { FolderOpen } from '@lucide/vue'
import { Button } from '@/components/ui/button'
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from '@/components/ui/empty'
</script>
<template>
<Empty>
<EmptyHeader>
<EmptyMedia><FolderOpen /></EmptyMedia>
<EmptyTitle>No projects yet</EmptyTitle>
<EmptyDescription>Create a project to start tracking work.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button>Create project</Button>
</EmptyContent>
</Empty>
</template>
Empty is a centred column. EmptyHeader groups the media, the title and the description and keeps them no wider than 24rem; EmptyContent does the same for the actions below. Anything else, such as a link, goes straight into Empty.
It draws no border and no background. The surface comes from what holds it: a Card, the empty slot of a DataTable, or the page itself. That keeps one empty state right in every place it appears, without variants that try to guess the container.
size runs from xs to xl and sets the padding and the gaps. A bare icon in EmptyMedia follows it too, from 24px to 56px, through --empty-icon on the root. The title and description keep text-title-md and text-body-md, so a text-* class of your own on them wins. md by default.
EmptyTitle is an h3. Set as to the level that fits the page, h2 on an empty page and h4 inside a card that already has a heading.
Examples
In a card
The card draws the border and the radius; the empty state only fills it.
In a table
A DataTable with no rows renders its empty slot in a centred cell that already pads and mutes its content, so this one drops its own padding and restores the text colour with class.
Avatars
EmptyMedia takes anything, here an AvatarGroup. Only a bare svg is sized by the root; other content keeps its own size.
Search
An empty state without media, with an InputGroup in the content and a second description under it.
API Reference
Every part accepts class, merged over its base classes.
Empty
| Prop | Default | Type and description |
|---|---|---|
| size | "md" | EmptySizeSets the padding and the gaps, and through them the icon, title and description sizes of the parts inside, from |
| Slot | Scope and description |
|---|---|
| default | {}The header, the content and anything else, stacked and centred. |
EmptyHeader
| Slot | Scope and description |
|---|---|
| default | {}The media, the title and the description, centred and no wider than 24rem. |
EmptyMedia
| Slot | Scope and description |
|---|---|
| default | {}An icon, an avatar or an image. A bare |
EmptyTitle
| Prop | Default | Type and description |
|---|---|---|
| asChild | — | booleanRender the single child instead of a wrapper, merging the title's attributes and classes onto it. |
| as | "h3" | AsTag | ComponentThe element to render. An |
| Slot | Scope and description |
|---|---|
| default | {}The title. |
EmptyDescription
| Slot | Scope and description |
|---|---|
| default | {}The description, in |
EmptyContent
| Slot | Scope and description |
|---|---|
| default | {}Actions or a form, stacked and centred, no wider than 24rem. |
Props
- size
"md" EmptySizeSets the padding and the gaps, and through them the icon, title and description sizes of the parts inside, fromxstoxl.mdby default.
Slots
- default
{}The header, the content and anything else, stacked and centred.
Slots
- default
{}The media, the title and the description, centred and no wider than 24rem.
Slots
- default
{}An icon, an avatar or an image. A baresvgtakes its size from the root'ssize, from 24px atxsto 56px atxl; anything with its own size keeps it.
Props
- asChild
booleanRender the single child instead of a wrapper, merging the title's attributes and classes onto it.- as
"h3" AsTag | ComponentThe element to render. Anh3by default; pick the level that fits the page.
Slots
- default
{}The title.
Slots
- default
{}The description, in--muted-foreground. Links inside are underlined and turn--primaryon hover.
Slots
- default
{}Actions or a form, stacked and centred, no wider than 24rem.
Data attributes
| data-slot | Attributes | Description |
|---|---|---|
| empty | data-size | The root. The parts read data-size through the group/empty class. |
| empty-header | — | The media, title and description. |
| empty-media | — | The icon, avatar or image. |
| empty-title | — | The heading, an h3 unless as says otherwise. |
| empty-description | — | The muted paragraph. |
| empty-content | — | The actions. |