Empty
没内容时放这儿。图标走 IconTile,标题、描述、底下还能塞点东西。
Installation
pnpm dlx @weme-ui/weme-ui add emptyUsage
No results
Try adjusting your search or filters to find what you need.
Vueexamples/usage.vueExpand codeHide code
<script lang="ts" setup>
import Empty from '../empty.vue'
</script>
<template>
<Empty icon="ri:inbox-line">
<template #title> No results </template>
<template #description> Try adjusting your search or filters to find what you need. </template>
</Empty>
</template>Examples
With Icon
Icon string
Pass an Iconify name to `icon`.
IconTile props
Pass an object to customize `IconTile`.
Vueexamples/with-icon.vueExpand codeHide code
<script lang="ts" setup>
import Empty from '../empty.vue'
</script>
<template>
<div class="flex flex-col gap-8 w-full">
<Empty icon="ri:search-line">
<template #title> Icon string </template>
<template #description> Pass an Iconify name to `icon`. </template>
</Empty>
<Empty
:icon="{
icon: 'ri:folder-open-line',
color: 'accent',
variant: 'soft',
}"
>
<template #title> IconTile props </template>
<template #description> Pass an object to customize `IconTile`. </template>
</Empty>
</div>
</template>With Content
No files yet
Upload a file or create a new one to get started.
Vueexamples/with-content.vueExpand codeHide code
<script lang="ts" setup>
import Button from '../../button/button.vue'
import Empty from '../empty.vue'
</script>
<template>
<Empty icon="ri:file-add-line">
<template #title> No files yet </template>
<template #description> Upload a file or create a new one to get started. </template>
<template #content>
<Button label="Create file" size="sm" />
</template>
</Empty>
</template>Sizes
Small
Compact empty state.
Medium
Default empty state.
Large
Emphasized empty state.
Vueexamples/sizes.vueExpand codeHide code
<script lang="ts" setup>
import Empty from '../empty.vue'
</script>
<template>
<div class="flex flex-col gap-8 w-full">
<Empty icon="ri:inbox-line" size="sm">
<template #title> Small </template>
<template #description> Compact empty state. </template>
</Empty>
<Empty icon="ri:inbox-line" size="md">
<template #title> Medium </template>
<template #description> Default empty state. </template>
</Empty>
<Empty icon="ri:inbox-line" size="lg">
<template #title> Large </template>
<template #description> Emphasized empty state. </template>
</Empty>
</div>
</template>Unstyled
Unstyled
Structure only; style via `class` / `ui`.
Vueexamples/unstyled.vueExpand codeHide code
<script lang="ts" setup>
import Empty from '../empty.vue'
</script>
<template>
<Empty icon="ri:inbox-line" :unstyled="true" class="text-left gap-4 items-start">
<template #title> Unstyled </template>
<template #description> Structure only; style via `class` / `ui`. </template>
</Empty>
</template>Props
PropTypeDefault
size'sm' | 'md' | 'lg''md'
尺寸;同时映射内置
IconTile 的 size(sm→xs,md→sm,lg→md)'sm' | 'md' | 'lg''md'
iconIconifyIconProps['icon'] | IconTileProps-
图标;字符串为 Iconify 名,或传入
IconTile 的 props。默认 variant="soft",可被对象覆盖;size 始终按映射IconifyIconProps['icon'] | IconTileProps-
titlestring-
标题文案;无
title 插槽时作为默认内容string-descriptionstring-
描述文案;无
description 插槽时作为默认内容string-unstyledboolean-
移除样式变体类,仅保留结构
boolean-classany-
根节点额外 class
any-uiPartial<EmptyStyleSlots>-
覆盖 slots 样式(
root / header / media / title / description / content)Partial<EmptyStyleSlots>-
Slots
SlotDescription
header自定义整块头部(含 media / title / description);未传时渲染默认头部结构
自定义整块头部(含 media / title / description);未传时渲染默认头部结构
media自定义媒体区;未传且提供 icon 时渲染 IconTile(默认 variant="soft",size 随 Empty 映射);无插槽且无 icon 时不渲染
自定义媒体区;未传且提供
icon 时渲染 IconTile(默认 variant="soft",size 随 Empty 映射);无插槽且无 icon 时不渲染title标题内容;未传时回退到 title prop;无插槽且无 prop 时不渲染
标题内容;未传时回退到
title prop;无插槽且无 prop 时不渲染description描述内容;未传时回退到 description prop;无插槽且无 prop 时不渲染
描述内容;未传时回退到
description prop;无插槽且无 prop 时不渲染content底部内容(如操作按钮);未提供该插槽时不渲染容器
底部内容(如操作按钮);未提供该插槽时不渲染容器
Accessibility
默认是 div(Reka UI Primitive)。里头的 IconTile 固定 aria-hidden="true"。可读的字放在 title / description(或对应插槽)里。
Files
src/components/empty/empty.vuesrc/components/empty/empty.props.tssrc/components/empty/empty.style.ts