Show · Empty

Empty

Placeholder component when the page is empty.

Demos

How to import

import { Empty } from '@fibrous/semi-ui-react';

Basic usage

By setting a placeholder image with image, you can manually import the corresponding illustration from @fibrous/semi-illustrations-react (the default width and height of the illustration is 200x200), or you can import a custom illustration.

A series of dark mode illustrations are added, and the illustrations that need to be used in dark mode can be passed in through darkModeImage to better adapt to the dark mode.

An empty string image counts as no image, and the title is laid out as if there were none.

功能建设中
当前功能暂未开放,敬请期待。
Code
import { IllustrationConstruction, IllustrationConstructionDark } from '@fibrous/semi-illustrations-react';
import { Empty } from '@fibrous/semi-ui-react';

export default function EmptyDemo() {
    return <Empty image={<IllustrationConstruction style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationConstructionDark style={{ width: 150, height: 150 }} />} title="功能建设中" description="当前功能暂未开放,敬请期待。" />;
}

Custom content

Description content goes in the description prop, and children is the actions area below it.

空状态标题
开始创建你的第一个仪表盘吧!
Code
import { IllustrationNoContent, IllustrationNoContentDark } from '@fibrous/semi-illustrations-react';
import { Empty, Button } from '@fibrous/semi-ui-react';

export default function EmptyDemo() {
    return (
        <Empty image={<IllustrationNoContent style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationNoContentDark style={{ width: 150, height: 150 }} />} title="空状态标题" description="开始创建你的第一个仪表盘吧!">
            <div>
                <Button style={{ padding: '6px 24px', marginRight: 12 }} type="primary">
                    二级按钮
                </Button>
                <Button style={{ padding: '6px 24px' }} theme="solid" type="primary">
                    一级按钮
                </Button>
            </div>
        </Empty>
    );
}

It is not necessary to use pictures.

暂未找到匹配的筛选结果
Code
import { Empty, Typography } from '@fibrous/semi-ui-react';

export default function EmptyDemo() {
    return (
        <Empty
            title="暂未找到匹配的筛选结果"
            description={
                <span>
                    <Typography.Text>试试 </Typography.Text>
                    <Typography.Text link>重置筛选条件</Typography.Text>
                </span>
            }
        />
    );
}

Different layout

Two types of layouts are supported: vertical, horizontal. The default is vertical.

创建成功
这是一段很长的描述文本,当文本过长的时候推荐使用这种布局形式。这是一段很长的描述文本,当文本过长的时候推荐使用这种布局形式。这是一段很长的描述文本,当文本过长的时候推荐使用这种布局形式。
Code
import { IllustrationSuccess, IllustrationSuccessDark } from '@fibrous/semi-illustrations-react';
import { Empty, Button } from '@fibrous/semi-ui-react';

export default function EmptyDemo() {
    return (
        <Empty
            title="创建成功"
            image={<IllustrationSuccess style={{ width: 150, height: 150 }} />}
            darkModeImage={<IllustrationSuccessDark style={{ width: 150, height: 150 }} />}
            layout="horizontal"
            description="这是一段很长的描述文本,当文本过长的时候推荐使用这种布局形式。这是一段很长的描述文本,当文本过长的时候推荐使用这种布局形式。这是一段很长的描述文本,当文本过长的时候推荐使用这种布局形式。"
            style={{ width: 800, margin: '0 auto' }}
        >
            <Button type="primary" theme="solid" style={{ padding: '6px 24px' }}>
                开始操作
            </Button>
        </Empty>
    );
}

Placeholder illustration (under construction)

Currently the following illustrations are supported in @fibrous/semi-illustrations-react (@fibrous/semi-illustrations-vue for Vue).

创建成功
加载失败
没有权限
暂无内容,请添加
页面404
搜索无结果
建设中
神游四方
Code
import {
    IllustrationConstruction,
    IllustrationSuccess,
    IllustrationFailure,
    IllustrationNoAccess,
    IllustrationNoContent,
    IllustrationNotFound,
    IllustrationNoResult,
    IllustrationIdle,
    IllustrationIdleDark,
    IllustrationConstructionDark,
    IllustrationSuccessDark,
    IllustrationFailureDark,
    IllustrationNoAccessDark,
    IllustrationNoContentDark,
    IllustrationNotFoundDark,
    IllustrationNoResultDark,
} from '@fibrous/semi-illustrations-react';
import { Empty } from '@fibrous/semi-ui-react';

export default function EmptyDemo() {
    const emptyStyle = {
        padding: 30,
    };
    return (
        <div style={{ display: 'flex', flexWrap: 'wrap' }}>
            <Empty image={<IllustrationSuccess style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationSuccessDark style={{ width: 150, height: 150 }} />} description="创建成功" style={emptyStyle} />
            <Empty image={<IllustrationFailure style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationFailureDark style={{ width: 150, height: 150 }} />} description="加载失败" style={emptyStyle} />
            <Empty image={<IllustrationNoAccess style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationNoAccessDark style={{ width: 150, height: 150 }} />} description="没有权限" style={emptyStyle} />
            <Empty image={<IllustrationNoContent style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationNoContentDark style={{ width: 150, height: 150 }} />} description="暂无内容,请添加" style={emptyStyle} />
            <Empty image={<IllustrationNotFound style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationNotFoundDark style={{ width: 150, height: 150 }} />} description="页面404" style={emptyStyle} />
            <Empty image={<IllustrationNoResult style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationNoResultDark style={{ width: 150, height: 150 }} />} description="搜索无结果" style={emptyStyle} />
            <Empty image={<IllustrationConstruction style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationConstructionDark style={{ width: 150, height: 150 }} />} description="建设中" style={emptyStyle} />
            <Empty image={<IllustrationIdle style={{ width: 150, height: 150 }} />} darkModeImage={<IllustrationIdleDark style={{ width: 150, height: 150 }} />} description="神游四方" style={emptyStyle} />
        </div>
    );
}

API reference

Props

PropertyDescriptionTypeDefault
childrenActions below the description, such as buttons.React.ReactNode-
classNameClass name of the root element.string-
darkModeImagePlaceholder image in dark mode, following the theme-mode attribute of document.body. Takes the same values as image.React.ReactNode | SVGNode-
descriptionDescription content, shown below the title.React.ReactNode-
imagePlaceholder image: a ReactNode such as an illustration component, an image URL string, or an in-page SVG sprite symbol as { id }. An empty string counts as no image.React.ReactNode | SVGNode-
imageStyleInline style of the placeholder image area, typed as CSSProperties.React.CSSProperties-
layoutLayout mode: vertical or horizontal.'vertical' | 'horizontal'"vertical"
refReference to the root div element.TypeReact.Ref<HTMLDivElement>-
styleInline style of the root element.React.CSSProperties-
titleTitle, rendered in the title style. Accepts any ReactNode.React.ReactNode-

Other native attributes (such as id and aria-*) land on the root div element.

Accessibility

ARIA

  • Empty illustrations are decorative: an SVG illustration has aria-hidden="true", and an img rendered from an image URL has an empty alt
  • title is styled as a heading but rendered as a div without heading semantics, so it does not disturb the page's heading levels

Content Guidelines

  • Title
    • The title should be concise and easy to understand
  • Text
    • The specific reasons for displaying the empty state can be displayed, and the subsequent operation behavior can also be displayed to help the user eliminate the empty state
    • Don't repeat the content on the title
    • Try to keep the body text within 1-2 sentences
  • Action button
    • Button copy needs to be clear and easy to understand
    • Use the verb + noun format

Design Token

These are the component's internal Sass variables and cannot be overridden. To customize styles, override the --semi-* CSS variables (see the Design Token page) or write unlayered CSS rules.
Sass variableValueUsage
$spacing-empty_content_vertical-marginTop24px垂直布局内容顶部外边距
$spacing-empty_content_horizontal-marginLeft32px水平布局内容左侧外边距
$spacing-empty_title-marginTop16px标题内容顶部外边距
$spacing-empty_footer-marginTop24px操作 footer 顶部外边距
$font-empty_title-fontWeight600标题字重
$color-empty_description-text-defaultvar(--semi-color-text-1)描述文字颜色

FAQ