Demos
How to import
<script setup lang="ts">
import { Empty } from '@fibrous/semi-ui-vue';
</script>
Basic usage
Set a placeholder image with the #image slot. You can manually import the corresponding illustration from @fibrous/semi-illustrations-vue (the default width and height of the illustration is 200x200), or put in a custom illustration. The image prop only takes an image URL string or { id }.
A series of dark mode illustrations are added, and the illustrations that need to be used in dark mode can be put in the #darkModeImage slot 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
<script setup lang="ts">
import { IllustrationConstruction, IllustrationConstructionDark } from '@fibrous/semi-illustrations-vue';
import { Empty } from '@fibrous/semi-ui-vue';
const imageStyle = { width: '150px', height: '150px' };
</script>
<template>
<Empty title="功能建设中">
<template #image>
<IllustrationConstruction :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationConstructionDark :style="imageStyle" />
</template>
<template #description>当前功能暂未开放,敬请期待。</template>
</Empty>
</template>Custom content
Description content goes in the #description slot, and the default slot is the actions area below it.
Code
<script setup lang="ts">
import { IllustrationNoContent, IllustrationNoContentDark } from '@fibrous/semi-illustrations-vue';
import { Button, Empty } from '@fibrous/semi-ui-vue';
const imageStyle = { width: '150px', height: '150px' };
</script>
<template>
<Empty title="空状态标题">
<template #image>
<IllustrationNoContent :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationNoContentDark :style="imageStyle" />
</template>
<template #description>开始创建你的第一个仪表盘吧!</template>
<div>
<Button :style="{ padding: '6px 24px', marginRight: '12px' }" type="primary">二级按钮</Button>
<Button :style="{ padding: '6px 24px' }" theme="solid" type="primary">一级按钮</Button>
</div>
</Empty>
</template>It is not necessary to use pictures.
Code
<script setup lang="ts">
import { Empty, Typography } from '@fibrous/semi-ui-vue';
const { Text } = Typography;
</script>
<template>
<Empty title="暂未找到匹配的筛选结果">
<template #description>
<span>
<Text>试试 </Text>
<Text link>重置筛选条件</Text>
</span>
</template>
</Empty>
</template>Different layout
Two types of layouts are supported: vertical, horizontal. The default is vertical.
Code
<script setup lang="ts">
import { IllustrationSuccess, IllustrationSuccessDark } from '@fibrous/semi-illustrations-vue';
import { Button, Empty } from '@fibrous/semi-ui-vue';
const imageStyle = { width: '150px', height: '150px' };
</script>
<template>
<Empty layout="horizontal" :style="{ width: '800px', margin: '0 auto' }" title="创建成功">
<template #image>
<IllustrationSuccess :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationSuccessDark :style="imageStyle" />
</template>
<template #description> 这是一段很长的描述文本,当文本过长的时候推荐使用这种布局形式。这是一段很长的描述文本,当文本过长的时候推荐使用这种布局形式。这是一段很长的描述文本,当文本过长的时候推荐使用这种布局形式。 </template>
<Button :style="{ padding: '6px 24px' }" theme="solid" type="primary">开始操作</Button>
</Empty>
</template>Placeholder illustration (under construction)
Currently the following illustrations are supported in @fibrous/semi-illustrations-react (@fibrous/semi-illustrations-vue for Vue).
Code
<script setup lang="ts">
import {
IllustrationConstruction,
IllustrationConstructionDark,
IllustrationFailure,
IllustrationFailureDark,
IllustrationIdle,
IllustrationIdleDark,
IllustrationNoAccess,
IllustrationNoAccessDark,
IllustrationNoContent,
IllustrationNoContentDark,
IllustrationNotFound,
IllustrationNotFoundDark,
IllustrationNoResult,
IllustrationNoResultDark,
IllustrationSuccess,
IllustrationSuccessDark,
} from '@fibrous/semi-illustrations-vue';
import { Empty } from '@fibrous/semi-ui-vue';
const emptyStyle = { padding: '30px' };
const imageStyle = { width: '150px', height: '150px' };
</script>
<template>
<div :style="{ display: 'flex', flexWrap: 'wrap' }">
<Empty :style="emptyStyle">
<template #image>
<IllustrationSuccess :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationSuccessDark :style="imageStyle" />
</template>
<template #description>创建成功</template>
</Empty>
<Empty :style="emptyStyle">
<template #image>
<IllustrationFailure :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationFailureDark :style="imageStyle" />
</template>
<template #description>加载失败</template>
</Empty>
<Empty :style="emptyStyle">
<template #image>
<IllustrationNoAccess :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationNoAccessDark :style="imageStyle" />
</template>
<template #description>没有权限</template>
</Empty>
<Empty :style="emptyStyle">
<template #image>
<IllustrationNoContent :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationNoContentDark :style="imageStyle" />
</template>
<template #description>暂无内容,请添加</template>
</Empty>
<Empty :style="emptyStyle">
<template #image>
<IllustrationNotFound :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationNotFoundDark :style="imageStyle" />
</template>
<template #description>页面404</template>
</Empty>
<Empty :style="emptyStyle">
<template #image>
<IllustrationNoResult :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationNoResultDark :style="imageStyle" />
</template>
<template #description>搜索无结果</template>
</Empty>
<Empty :style="emptyStyle">
<template #image>
<IllustrationConstruction :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationConstructionDark :style="imageStyle" />
</template>
<template #description>建设中</template>
</Empty>
<Empty :style="emptyStyle">
<template #image>
<IllustrationIdle :style="imageStyle" />
</template>
<template #darkModeImage>
<IllustrationIdleDark :style="imageStyle" />
</template>
<template #description>神游四方</template>
</Empty>
</div>
</template>API reference
Props
| Property | Description | Type | Default |
|---|---|---|---|
| layout | Layout mode: vertical or horizontal. | "vertical" | "horizontal" | semiDefault("Empty", "layout", "vertical") |
| imageStyle | Style of the placeholder image. | CSSProperties | semiGlobalDefault("Empty", "imageStyle") |
| title | Plain-text title. The title slot wins when both are given. | string | semiGlobalDefault("Empty", "title") |
| image | Placeholder image URL, or an in-page SVG sprite symbol as { id }. An empty string counts as no image. Use the image slot for other content. | string | EmptySvgNode | semiGlobalDefault("Empty", "image") |
| darkModeImage | Placeholder image in dark mode, following the theme-mode attribute of document.body. Takes the same values as image. | string | EmptySvgNode | semiGlobalDefault("Empty", "darkModeImage") |
Events
| Event | Description | Callback parameters |
|---|---|---|
| None |
Slots
| Slot | Description | Scope parameters |
|---|---|---|
| default | Actions below the description. | any |
| title | Custom title, preferred over the title prop. | any |
| description | Description content. | any |
| image | Custom placeholder image, preferred over the image prop. | any |
| darkModeImage | Custom placeholder image in dark mode, preferred over the darkModeImage prop. | any |
Exposes
| Name | Description | Type |
|---|---|---|
| None |
class, style and native attributes are passed through attrs to the root element. title is a component prop and does not land on the root element as an HTML attribute. In dark mode every Empty observes theme-mode on document.body after mount; server render and hydration use the light image.
Accessibility
ARIA
- Empty illustrations are decorative: an SVG illustration has
aria-hidden="true", and animgrendered from an image URL has an emptyalt titleis styled as a heading but rendered as adivwithout 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
| Sass variable | Value | Usage |
|---|---|---|
| $spacing-empty_content_vertical-marginTop | 24px | 垂直布局内容顶部外边距 |
| $spacing-empty_content_horizontal-marginLeft | 32px | 水平布局内容左侧外边距 |
| $spacing-empty_title-marginTop | 16px | 标题内容顶部外边距 |
| $spacing-empty_footer-marginTop | 24px | 操作 footer 顶部外边距 |
| $font-empty_title-fontWeight | 600 | 标题字重 |
| $color-empty_description-text-default | var(--semi-color-text-1) | 描述文字颜色 |