EmptyState
What stands in for content that is not there, and why it is not.
Examples
Playground
Add your first colour
Add by hex or extract from an image.
The three situations
Add your first colour
Add by hex or extract from an image.
No colours match this filter
Try a wider search, or clear the filter.
Couldn’t open your library
The file is there but could not be read.
Title only
No results
With icon
The `icon` slot sits above the title as the visual anchor for the block. A slot is invisible until something is put in it, so it gets a story of its own. haus ships no icon set, so the glyph is the consumer’s: this is a plain inline SVG using `currentColor`, which the `.icon` rule colours.
Add your first colour
Add by hex or extract from an image.
Install
npx shadcn add @hipuku/empty-stateUsage
import { EmptyState } from '@/components/haus/components/EmptyState'
<EmptyState
title="No colours yet"
description="Add one by hex, or extract a palette from an image."
action={<Button variant="primary">Add a colour</Button>}
/>API
EmptyState also takes its element's own attributes and forwards its ref. className lands on the
root.
| Prop | Type | Description |
|---|---|---|
titlerequired | string | Why the region is empty, in a few words. Required, and it is the whole component. An empty region with no explanation is indistinguishable from one that has not loaded, and the writing is the part a design system can actually standardise: what a never-had-anything state says, and how a filtered-to-nothing state says something different. |
description | string | |
action | React.ReactNode | The thing that fills the void. Omit it where nothing the reader can do would: a filtered-to-nothing state wants "clear the filter", and a permissions one wants no button at all. |
icon | React.ReactNode | An illustration or glyph. Decorative: the title carries the meaning. |
headingLevel | EmptyStateHeadingLevel | |
live | "off" | "polite" |
Writing it
An empty state is mostly a sentence, and there are three different ones:
| Situation | Say | Action |
|---|---|---|
| Nothing yet | There is nothing here, and how to start | The control that starts it |
| Filtered to nothing | The filter is too narrow | Clear the filter |
| Could not load | It failed, which is not the same as empty | Retry, or none |
Leave out action when nothing the reader can do would fill the space.
Set live="polite" when the empty state appears in response to something, such as a search with
no results or a failed load. Otherwise it is not announced, and a failure reads as an empty list.
Accessibility
titleis a real heading. SetheadingLevelto fit the page: it defaults to3.- The icon is decorative. The title carries the meaning.
- The action keeps its own place in the tab order.