Empty State
What a list, a table or a page says while it has nothing to show, and the action that fills it.
No transfers yet
Installation
pnpm dlx @human-kit/design add empty-statenpx @human-kit/design add empty-stateyarn dlx @human-kit/design add empty-statebunx @human-kit/design add empty-stateThe command copies the files to src/lib/components/ui/empty-state. It also
installs the packages that the files import.
Usage
<script lang="ts">
import * as EmptyState from '$lib/components/ui/empty-state';
</script>
<EmptyState.Root title="No invoices yet">
Invoices appear here once a sale is closed.
</EmptyState.Root> Examples
Your own mark
Give icon a snippet to replace the tray. A search that found nothing says so with a mark of its own, and its action clears the filter rather than creating a record.
No patients match “Restrepo”
Guidelines
- Use
ghostinside something that already is a surface: the body of a table, a panel, a page. - Use
outlinefor a section of a page that would otherwise be blank, so it still reads as a place. - Use
sminside a list, a menu or a popover: it drops the mark and keeps one line of help. - Say why it is empty or what will appear here, not only that it is empty: "Transfers appear here once a date is set".
- Offer the one action that fills it, a small button in
actions. A search with no results offers to clear the filter instead.
Accessibility
- It renders a plain
<div>with a paragraph for the title: no role and no live region, since it is content, not an alert. - The mark is hidden from assistive technology. The title and the line under it carry the meaning.
- When it replaces the rows of a list as the user types a search, say so elsewhere too, in a live region with the count of results: the swap alone is silent.
- The buttons in
actionsare reached with Tab like any other.
API reference
| Prop | Type | Default |
|---|---|---|
variant | 'outline' | 'filled' | 'ghost' On a card of its own, on a soft grey, or bare. | 'ghost' |
size | 'sm' | 'default'
| 'default' |
title | string What is empty, in a few words. | — |
children | Snippet The line on why it is empty, or what will appear here. | — |
actions | Snippet The buttons that fill it: | — |
icon | Snippet Your own mark in place of the tray. Not drawn at | — |
Plus every attribute of a <div> but title, which is the heading here.