feat: add Typography EmptyState and Breadcrumbs
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
---
|
||||
title: EmptyState 空状态
|
||||
description: 在列表、搜索结果或集合为空时展示占位提示。
|
||||
component: empty-state
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { EmptyState } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<EmptyState />
|
||||
</template>
|
||||
```
|
||||
|
||||
<ComponentPreview name="empty-state-default" />
|
||||
|
||||
> 基线说明:固定上游提交提供 `EmptyState` 源码与样式,但没有独立中文组件页或官方演示。本页与以下示例由本项目依据真实源码(默认文案 `No results found`)和现有空状态消费场景编写,不是上游官方文档内容。
|
||||
|
||||
## 组件结构
|
||||
|
||||
`EmptyState` 是单根展示组件,默认渲染 `div`,样式为基线 `.empty-state` 的 `hv-` 命名空间版本。
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<EmptyState>
|
||||
<span>没有找到匹配的搜索结果。</span>
|
||||
</EmptyState>
|
||||
</template>
|
||||
```
|
||||
|
||||
默认插槽为空、仅包含注释或空白文本时,回退到源码默认文案 `No results found`。只要存在有效内容(文本、数字或元素),就渲染调用方内容,不额外包裹结构。
|
||||
|
||||
## 示例
|
||||
|
||||
### 默认回退
|
||||
|
||||
不提供内容时展示源码默认文案。
|
||||
|
||||
<ComponentPreview name="empty-state-default" />
|
||||
|
||||
### 自定义文案
|
||||
|
||||
<ComponentPreview name="empty-state-custom-content" />
|
||||
|
||||
### 条件内容
|
||||
|
||||
插槽内容由 `v-if` 切换;内容为空时自动回退到默认文案。
|
||||
|
||||
<ComponentPreview name="empty-state-conditional" />
|
||||
|
||||
### 自定义样式
|
||||
|
||||
`class` 与 `$attrs` 合并到根元素,可叠加边框、背景、间距与对齐工具类。
|
||||
|
||||
<ComponentPreview name="empty-state-custom-styles" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="empty-state-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-empty-state {
|
||||
@apply py-8 text-center text-base;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
EmptyState 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/empty-state.css)):
|
||||
|
||||
- `.hv-empty-state` - 基础空状态文本样式(`p-2 text-sm text-muted`)
|
||||
|
||||
基线没有尺寸、颜色、变体或图标插槽等额外 CSS 变体;需要更丰富的空状态布局时,由调用方组合内容与工具类。
|
||||
|
||||
## API 参考
|
||||
|
||||
### EmptyState
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| -------- | --------------------------- | ------- | ------------------------------------------------ |
|
||||
| `as` | `string` | `'div'` | 自定义根元素标签;对应上游 `render` 的元素替换。 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定)。 |
|
||||
| 默认插槽 | - | - | 空状态内容;无有效内容时回退默认文案。 |
|
||||
|
||||
`$attrs`(`aria-*`、`data-*`、`id`、`style`、事件等)透传至根元素。组件没有受控值、内部状态、事件或暴露方法。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Typography 排版](./typography) · [SearchField 搜索框](./search-field)
|
||||
Reference in New Issue
Block a user