Skip to the content
human-kit design
57 — Feedback

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

Frozen embryo transfers for this patient will appear here once a date is set.

Installation

pnpm dlx @human-kit/design add empty-state
npx @human-kit/design add empty-state
yarn dlx @human-kit/design add empty-state
bunx @human-kit/design add empty-state

The 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”

Check the spelling, or search by document number instead.

Guidelines

  • Use ghost inside something that already is a surface: the body of a table, a panel, a page.
  • Use outline for a section of a page that would otherwise be blank, so it still reads as a place.
  • Use sm inside 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 actions are reached with Tab like any other.

API reference

PropTypeDefault
variant'outline' | 'filled' | 'ghost'

On a card of its own, on a soft grey, or bare.

'ghost'
size'sm' | 'default'

sm has no mark and less room, for a list or a popover.

'default'
titlestring

What is empty, in a few words.

—
childrenSnippet

The line on why it is empty, or what will appear here.

—
actionsSnippet

The buttons that fill it: <Button.Root size="sm">.

—
iconSnippet

Your own mark in place of the tray. Not drawn at sm.

—

Plus every attribute of a <div> but title, which is the heading here.