Empty state

Slant / Feedback

What a view shows when it has nothing yet.

Demo

Usage

@tuttn/slant
import { Button, EmptyState, SearchIcon } from '@tuttn/slant'

<EmptyState title="No checkpoints yet"
  actions={<Button size="sm" variant="primary" onClick={create}>Create checkpoint</Button>}>
  A checkpoint saves the workspace before each agent run, so you can roll back.
</EmptyState>

// Smaller, with your own icon, and a paragraph title inside a section that
// already has a heading.
<EmptyState size="sm" titleAs="p" icon={<SearchIcon size={18} />} title="No results for “deploy”">
  Try a shorter search, or clear the filters.
</EmptyState>

Props

PropTypeDefaultDescription
titleReactNode—What is missing, in a few words: "No checkpoints yet".
childrenReactNode—The description under the title, in muted text: why the view is empty, or what fills it. Plain text or inline content; it renders in a div, so a `<Text>` paragraph is fine too.
iconReactNodea small cluster of slanted pixels, one of them a hollow slotThe mark above the title. It is decorative and hidden from screen readers, so the title has to say everything.
actionsReactNode—The next steps, usually one or two `<Button size="sm">`s, laid out in a centred row under the description.
size'sm' | 'md''md'md for a page, a card or a whole panel; sm for a list, a table body or a narrow column.
titleAs'h2' | 'h3' | 'h4' | 'p''h3'The title's element, to fit the page's heading outline; `p` when the empty state sits inside something that already has a heading.
…restHTMLAttributes<HTMLDivElement>—className, style, other attributes and the ref go on the root.

Keyboard

EmptyState adds no focus stops of its own: the actions are ordinary buttons or links, in the tab order in the order you pass them. When a view empties because of something the reader did and the control they used goes with it (a "Clear all" button, say), move focus to the first action, as the demo does; otherwise leave focus where it is.

Accessibility

The title is a heading, h3 unless titleAs says otherwise: pick the level that fits the page's outline, or p inside a card or panel that already has a heading. The mark above it, the default pixels or your icon, is decorative and hidden from screen readers, so the title has to say what is missing. The description is muted text that holds 4.5:1 in every theme. EmptyState is not a live region: if a view empties while someone is reading it, announce the change yourself, for example with an Alert and announce.

Direction

Everything is centred, and the layout is logical: under dir="rtl" the row of actions runs from the right and the pixel mark mirrors.