Feedback
Empty state
An empty state takes the place of a list or page that has nothing in it yet: it says what is missing in plain words and offers the next step, such as "No files yet" with "Attach file".
In kanso-ui as EmptyState
Web and native
EmptyState in kanso-ui 0.59.0, for React.
import { EmptyState } from '@kanso-labs/kanso-ui'What a screen, a list or a section draws when it has nothing to show.
No Material Design page draws an empty state, so its layouts are the library's own, built from the pages' parts: a mark in a filled circle, a title in title large, a line in body medium on on-surface-variant, and one common button. The rows follow the lists page's 56dp and 72dp items.
What you provide
description: the line saying what is empty, what is done, or what can be done about it. Required on the row forms, since it is all they say.title(firstandstatus): a heading, atheadingLevel(default2, under the app bar's<h1>).icon: the glyph in the mark,1emsquare incurrentColor; it is drawn at 32dp in a screen's mark and 20dp in a section's.donedraws its own check.action(firstandstatus):{ label, onPress }or{ label, href }, the one button.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
action | EmptyStateAction | — | The one button: the `accent` button for `first`, `tonal` for `status`. Its label names the outcome with a verb. The row forms draw none. |
description | ReactNode | — | The line saying what is empty, what is done, or what can be done about it: inline content, since it is drawn as a paragraph. The row forms need it, since it is all they say. |
headingLevel | 1 | 2 | 3 | 4 | 5 | 6 | 2 | Where the title sits in the page's outline, as one of the six heading levels. A value outside the six that reaches it untyped falls back to 2. |
icon | ReactNode | — | Deprecated on these two layouts, and drawn nowhere: Kanso's empty state shows the four status marks in place of an icon, and a development build warns once. Remove it. The section's row, `size="inline"`, still draws its icon. Not marked `@deprecated` in the types: tried, oxlint's `typescript/no-deprecated` flagged that row's `icon` too, since the union's members share the property. |
kind | 'first' | 'status' | 'first' | `first`, nothing there yet; `done`, nothing left; `status`, what was opened cannot be shown. |
size | 'default' | 'default' | `inline` draws `first` as a 72dp row for a section, with a 40dp mark and the line alone. |
title | ReactNode | — | The title, a heading in the page's outline. The row forms draw none. |
Also takes the props of EmptyStateBaseProps.
Example
import { EmptyState } from '@kanso-labs/kanso-ui'
<EmptyState
action={{ label: 'Label', onPress: add }}
description="Supporting line"
icon={icon}
title="Headline"
/>
<EmptyState size="inline" icon={icon} description="Supporting line" />
<EmptyState kind="done" description="Supporting line" />The design’s classes
k-empty, k-empty__marks, k-empty__title and k-empty__body, with k-mark k-mark--lg plus k-mark--circle, k-mark--pill, k-mark--diamond and k-mark--square, each with is-next, and k-btn k-btn--accent. New in Kanso: kanso-ui and react-native-kanso-ui have no empty state yet, and both gain an EmptyState.