Empty
elements man ui/templates/emptyThe empty state for a list, a search or a page, with media, a title, a description and next steps.
Exampleimport { Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent, } from "@elements/ui/empty"; import { Icon } from "@elements/ui/icon"; import { Button } from "@elements/ui/button"; <Empty title="No projects yet" description="Create your first project to get started."> <Icon slot="icon" name="folder" /> <EmptyContent> <Button variant="primary">Create project</Button> </EmptyContent> </Empty>
Empty grows to fill a flex container (flex: 1), so in a page's column it
centers itself in the space a list would have filled. To keep it the
height of its content, as in a column that fills the viewport, add the
flex-none utility.
Example<main class="stack"> <h1>Saved</h1> <Empty variant="outline" title="Nothing saved yet." class="flex-none" /> </main>
Parts
| Part | What it is |
|---|---|
EmptyHeader |
.empty-header: media, title, description. |
EmptyMedia |
.empty-media: an icon tile, an avatar, an image. |
EmptyTitle |
.empty-title, role=heading. |
EmptyDescription |
.empty-description, soft ink with underlined links. |
EmptyContent |
.empty-content: actions or a search field. |
.empty-actions |
A centered row of buttons. |
Attributes
Empty
| Attribute | Type | Default | Description |
|---|---|---|---|
title |
string |
"" |
Renders a header with a title. |
description |
string |
"" |
Renders a description in that header. |
variant |
"default" | "outline" | "muted" |
"default" |
outline is a dashed rule, muted a soft fill. |
level |
1 | 2 | 3 | 4 | 5 | 6 |
2 |
Heading level of the title. |
class |
string |
"" |
Extra classes. |
attrs |
Record<string, string | number | boolean | undefined> |
{} |
Other attributes for the root. |
EmptyMedia
| Attribute | Type | Default | Description |
|---|---|---|---|
variant |
"default" | "icon" |
"default" |
icon puts the icon on a muted tile. |
EmptyTitle
| Attribute | Type | Default | Description |
|---|---|---|---|
level |
1 | 2 | 3 | 4 | 5 | 6 |
2 |
aria-level. |
every part
| Attribute | Type | Default | Description |
|---|---|---|---|
class |
string |
"" |
Extra classes. |
Slots
| Slot | Part | Content |
|---|---|---|
icon |
Empty |
The icon for the header the title shortcut renders. |
default |
Empty |
Parts, or anything. |
default |
each part |
The part's content. |
Data attributes
| Attribute | Values | On |
|---|---|---|
data-variant |
"default" | "outline" | "muted" |
root |
data-variant |
"default" | "icon" |
EmptyMedia |
Accessibility
- The title is role="heading" (level 2 by default), so an empty page keeps its outline.
- No live region of its own: when it replaces search results, announce the result count from the search.
See also
- Icon (opens in a new tab): An inline stroke icon from the set the templates draw their own controls with, sized in pixels and colored by the text around it.
- Button (opens in a new tab): A button or a link that looks like one, in six variants and four sizes.
- Badge (opens in a new tab): A small label for a status, a count or a category, built on the pill.
- Card (opens in a new tab): A surface with a header, body and footer, built on the base card styles.
- Alert (opens in a new tab): A callout that draws attention to a message, with an icon, a title and an action.
- Kbd (opens in a new tab): A keyboard key or shortcut, as text.