- Docs
- Components
- Feedback
Empty state
The message where content would be: nothing yet, no results, or an error. DataState picks the right one.
- Import
- @qeetrix/react/experimental
- Status
- ExperimentalSince 0.0.4
- Renders
<div>Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Import
// Experimental: from the package's experimental entry, until it's stable.
import { EmptyState, DataState } from "@qeetrix/react/experimental";02
Props
And every native attribute of the element it renders.
| Prop | Type | Default | What it does |
|---|---|---|---|
title | ReactNode | required | What's missing or went wrong: "No users yet". |
description | ReactNode | — | One or two sentences: why, and what to do. |
icon | IconSource | — | A 24px sharp icon. |
actions | ReactNode | — | Buttons, one primary at most. |
children | ReactNode | — | Under the actions, small and subtle: a link. |
size | "page" | "section" | "page" | page for a whole view; section inside a card or a table. |
tone | "neutral" | "danger" | "neutral" | danger colours the icon. |
level | 2 – 6 | — | Makes the title a heading, when this is the page's main message. |
DataState: loading · error · empty | boolean · unknown · boolean | — | Which state: loading wins, then error, then empty, then the children. |
DataState: emptyState · onRetry | ReactNode · () => void | — | The EmptyState for empty; Try again for an error. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What it is |
|---|---|---|
empty-state | <div> | data-size, data-tone. |
empty-state-icon | <svg> | aria-hidden. |
empty-state-title | <p> | Or <h2>–<h6> with level. |
empty-state-actions | <div> | The actions. |
data-state | <div> | DataState's loading, error or empty region: data-state. |
04
In a table
Table's empty and error take an EmptyState and a DataState, under its header.
<Table
empty={<EmptyState size="section" icon={UsersIcon} title="No users yet" … />}
error={error && <DataState error={error} onRetry={refetch} />}
…
/>