组件 · 反馈
EmptyState
What a view shows when it has no content — a gray icon, a title, one sentence on why it is empty and what to do, and at most one button.
也叫 Empty, Blank slate
import { EmptyState } from "@botiverse/raft-ui";An empty state tells people why a view has no content and what to do next. It has one look everywhere: a gray icon with no frame, a gray title, one sentence, and at most one button. It is a conclusion ("there is nothing here"), so it never stands in for loading or a failure.
When to use
| Situation | Use |
|---|---|
| There is nothing here yet | EmptyState: why it is empty and how to make something appear |
| Filters or a search match nothing | EmptyState: which conditions are active, with Clear All |
| It is still loading | Skeleton, not an empty state |
| It failed to load | An error at its scope, with Retry (Feedback) |
Anatomy
EmptyState: the centered root. Required.EmptyStateContent: groups the icon, title and description. Required.EmptyStateIcon: a Lucide icon, at 36px inforeground-hint. Required.EmptyStateTitle: the title, inforeground-muted. Required.EmptyStateDescription: one sentence, inforeground-hint. A link in it is 600 with no underline at rest and underlines in ink on hover (Clickable text): the weight is what sets it apart from the grey sentence.EmptyStateActions: at most one button.
Content
- Write the title in sentence case and state the fact: "No tasks yet", "No tasks match these filters" (Writing).
- For a view with nothing yet, say in the description how something gets here.
- For filters or a search with no results, name the conditions that are active, and label the button Clear All.
Accessibility
EmptyStateIconis hidden from assistive technology (aria-hidden): the title says what is empty.- When the empty state is the only content of a page or panel, render the title as a heading (
render) at the level the page needs.
Rules
- Put the empty state directly in the middle of the content area. Don't wrap it in a card, frame the icon or add a sticker: empty states are working pages (Brand).
- Give it at most one button: a 32px ink-bordered button (
variant="default" size="md"), never pink. - Keep it quiet. The empty state is a hint, not a heading: small, faint type that doesn't compete with the button people should press next.
API
EmptyState, EmptyStateActions, EmptyStateContent, EmptyStateDescription, EmptyStateIcon, EmptyStateTitle
| Prop | 类型 | 默认值 |
|---|---|---|
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.
相关组件
改动
- 0.7.0 · Fixed
EmptyStateIconis hidden from assistive technology, andNotificationCenterItemIconis announced as an image named by its status.