feat: add Typography EmptyState and Breadcrumbs

This commit is contained in:
maoyingjie
2026-10-22 13:07:13 +08:00
parent bcadbeaf8c
commit e4d817ce55
50 changed files with 3130 additions and 90 deletions
+3
View File
@@ -49,6 +49,7 @@ const groups = [
{ title: "Avatar 头像", url: "/components/avatar" },
{ title: "AvatarGroup 头像组", url: "/components/avatar-group" },
{ title: "Badge 徽章", url: "/components/badge" },
{ title: "Breadcrumbs 面包屑", url: "/components/breadcrumbs" },
{ title: "Button 按钮", url: "/components/button" },
{ title: "Card 卡片", url: "/components/card" },
{ title: "Checkbox 复选框", url: "/components/checkbox" },
@@ -56,6 +57,7 @@ const groups = [
{ title: "Chip 标签", url: "/components/chip" },
{ title: "CloseButton 关闭按钮", url: "/components/close-button" },
{ title: "Description 描述", url: "/components/description" },
{ title: "EmptyState 空状态", url: "/components/empty-state" },
{ title: "FieldError 字段错误", url: "/components/field-error" },
{ title: "Fieldset 字段组", url: "/components/fieldset" },
{ title: "Input 输入框", url: "/components/input" },
@@ -72,6 +74,7 @@ const groups = [
{ title: "Switch 开关", url: "/components/switch" },
{ title: "TextArea 多行文本框", url: "/components/textarea" },
{ title: "TextField 文本输入框", url: "/components/text-field" },
{ title: "Typography 排版", url: "/components/typography" },
],
},
];
+3 -3
View File
@@ -194,7 +194,7 @@ button {
.breadcrumb span {
opacity: 0.5;
}
h1 {
.docs-main > h1 {
font-size: 32px;
font-weight: 600;
line-height: 1.25;
@@ -266,7 +266,7 @@ h1 {
.docs-content h3:hover .header-anchor {
opacity: 1;
}
.docs-content :not(pre) > code {
.docs-content :not(pre) > code:not(:where(.not-prose, .not-prose *)) {
background: var(--default);
border-radius: 5px;
padding: 2px 5px;
@@ -549,7 +549,7 @@ a:focus-visible {
padding: 20px;
min-height: 300px;
}
h1 {
.docs-main > h1 {
font-size: 28px;
}
.variant-card {
+3
View File
@@ -7,11 +7,13 @@ description: 已迁移组件及文档
- [Avatar 头像](./components/avatar)
- [AvatarGroup 头像组](./components/avatar-group)
- [Badge 徽章](./components/badge)
- [Breadcrumbs 面包屑](./components/breadcrumbs)
- [Button 按钮](./components/button)
- [Card 卡片](./components/card)
- [Chip 标签](./components/chip)
- [CloseButton 关闭按钮](./components/close-button)
- [Description 描述](./components/description)
- [EmptyState 空状态](./components/empty-state)
- [FieldError 字段错误](./components/field-error)
- [Input 输入框](./components/input)
- [InputGroup 输入框组](./components/input-group)
@@ -25,6 +27,7 @@ description: 已迁移组件及文档
- [Switch 开关](./components/switch)
- [TextArea 多行文本框](./components/textarea)
- [TextField 文本输入框](./components/text-field)
- [Typography 排版](./components/typography)
- [Fieldset 字段组](./components/fieldset)
- [SearchField 搜索框](./components/search-field)
+176
View File
@@ -0,0 +1,176 @@
---
title: Breadcrumbs 面包屑
description: 导航面包屑,显示当前页面在层级结构中的位置
component: breadcrumbs
group: 组件
---
## 用法
```vue
<script setup lang="ts">
import { Breadcrumbs, BreadcrumbsItem } from "@heroui-vue/components";
</script>
<template>
<Breadcrumbs>
<BreadcrumbsItem href="#">首页</BreadcrumbsItem>
<BreadcrumbsItem href="#">产品</BreadcrumbsItem>
<BreadcrumbsItem>笔记本电脑</BreadcrumbsItem>
</Breadcrumbs>
</template>
```
<ComponentPreview name="breadcrumbs-basic" />
## 组件结构
```vue
<script setup lang="ts">
import { Breadcrumbs, BreadcrumbsItem } from "@heroui-vue/components";
</script>
<template>
<Breadcrumbs>
<BreadcrumbsItem href="#">首页</BreadcrumbsItem>
<BreadcrumbsItem href="#">分类</BreadcrumbsItem>
<BreadcrumbsItem>当前页面</BreadcrumbsItem>
</Breadcrumbs>
</template>
```
`Breadcrumbs` 渲染为带可访问名称的 `ol`,`BreadcrumbsItem` 渲染为 `li`。最后一项自动成为当前页:附加 `aria-current="page"`,并作为不可导航的当前项处理。
## 示例
### 导航层级
<ComponentPreview name="breadcrumbs-level-2" />
<ComponentPreview name="breadcrumbs-level-3" />
### 禁用状态
<ComponentPreview name="breadcrumbs-disabled" />
`isDisabled` 禁用所有链接,并保留项目文本与分隔符。
### 自定义分隔符
<ComponentPreview name="breadcrumbs-custom-separator" />
上游通过 `separator` 属性接收自定义分隔符节点;Vue 版使用 `#separator` 具名插槽。自定义元素会获得分隔符尺寸类与 `data-slot="breadcrumbs-separator"`。
### 渲染函数
<ComponentPreview name="breadcrumbs-render-function" />
上游 `render` 用于替换根元素或传递额外属性;Vue 版通过 `as` 更换元素类型,普通属性与 `data-*` 直接透传到对应根元素。示例把 `data-custom` 放在 `ol` 与 `li` 上。
## 自定义样式
### Tailwind CSS
<ComponentPreview name="breadcrumbs-custom-styles" />
`BreadcrumbsItem` 的 `class` 同时合并到 `li` 与内部链接,便于定制当前项和悬停颜色;其他属性落在 `li` 根节点。
### 全局 CSS
可使用 `@layer components` 指令自定义 Breadcrumbs 组件类。
```css
@layer components {
.hv-breadcrumbs {
@apply gap-4 text-lg;
}
.hv-breadcrumbs__link {
@apply font-semibold;
}
.hv-breadcrumbs__separator {
@apply text-blue-500;
}
}
```
## 样式参考
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
### CSS 类
Breadcrumbs 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/breadcrumbs.css)):
#### 基础类 [!toc]
- `.hv-breadcrumbs` - 面包屑根容器
- `.hv-breadcrumbs__item` - 单个面包屑项包装器
- `.hv-breadcrumbs__link` - 面包屑链接元素
- `.hv-breadcrumbs__separator` - 项之间的分隔符图标
#### 状态类 [!toc]
- `.hv-breadcrumbs__link[data-current="true"]` - 当前页指示(不可导航)
- `.hv-breadcrumbs__link[aria-disabled="true"]` - 禁用链接
### 交互状态
- **Current**:最后一项的链接带有 `data-current="true"`、`aria-current="page"` 与 `aria-disabled="true"`。
- **Hover**:链接支持标准 hover 与 `data-hovered` 状态。
- **Disabled**:根级 `isDisabled` 或单项 `isDisabled` 以 `span[role="link"]` 呈现,带 `aria-disabled="true"`、`tabindex="-1"`,不保留 `href` 并阻止点击激活;元素类型与 React Aria Link 一致。共享 Vue Link 为禁用项保留 `tabindex="-1"` 以支持程序化聚焦,RAC 则省略 `tabindex`;两者都不能通过 Tab 聚焦。未提供 `href` 的非当前项同样渲染为 `span[role="link"]`,未禁用时 `tabindex="0"`。
固定基线没有自动折叠、省略号或“展开更多”状态机;本实现不额外添加。
## API 参考
### Breadcrumbs
| 属性 | 类型 | 默认值 | 描述 |
| ------------ | --------------------------- | --------------- | ------------------------------------------------ |
| `aria-label` | `string` | `'Breadcrumbs'` | 面包屑列表的可访问名称。 |
| `isDisabled` | `boolean` | `false` | 是否禁用所有面包屑链接。 |
| `as` | `string` | `'ol'` | 自定义根元素标签;对应上游 `render` 的元素替换。 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定)。 |
| 默认插槽 | - | - | `BreadcrumbsItem` 列表。 |
| `#separator` | - | 默认右箭头图标 | 自定义各项之间的分隔符。 |
根元素同时接收其余 `$attrs`(`data-*`、`id`、`style`、事件等);`aria-label` 为空字符串时回退为 `Breadcrumbs`。`isDisabled` 通过既有禁用作用域传给内部 `Link`,不复制禁用逻辑。
### BreadcrumbsItem
| 属性 | 类型 | 默认值 | 描述 |
| ------------ | --------------------------- | --------- | -------------------------------------------------------------------------------- |
| `href` | `string` | - | 链接 URL;未提供时渲染不可导航的 `span[role="link"]`,当前项与禁用项也不可导航。 |
| `target` | `string` | `'_self'` | 链接目标;仅在带 `href` 的可导航项输出。 |
| `rel` | `string` | - | 链接关系。 |
| `download` | `boolean \| string` | - | 原生下载属性。 |
| `isDisabled` | `boolean` | `false` | 禁用当前项链接。 |
| `as` | `string` | `'li'` | 自定义项元素标签;对应上游 `render` 的元素替换。 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类;同时合并到 `li` 与内部链接。 |
| 默认插槽 | `{ isCurrent, isDisabled }` | - | 项内容;可用作用域状态渲染条件内容。 |
`li` 根节点接收除事件处理器外的 `$attrs`;`onClick`、`onKeydown`、`onFocus` 等事件绑定到真实链接,从而复用 `Link` 的禁用拦截与事件顺序。`isLast` 和 `separatorSlot` 由 `Breadcrumbs` 自动注入,不列入公开 `BreadcrumbsItemProps` 类型或 API 表,调用方无需设置。
### 上游差异
| 上游 React 能力 | Vue 实现 |
| ----------------------------- | ------------------------------------------ |
| `Breadcrumbs.Item` 对象子部件 | 独立具名导出 `BreadcrumbsItem` |
| `separator: ReactNode` | `#separator` 插槽,默认图标从基线 SVG 移植 |
| `render` 函数 | `as` 更换元素,属性直接透传 |
| `className` / `children` | `class` / 默认插槽 |
| `onAction` | 未提供;使用链接原生行为或 `@click` |
## 无障碍
- 根元素是 `ol`,默认带 `aria-label="Breadcrumbs"`。固定基线的 React Aria Components `Breadcrumbs` 实际渲染 `ol` 而不是 `nav`;中文文档中的“导航地标”描述与源码 DOM 不完全一致,本实现以固定提交源码为准。需要独立导航地标时,可由应用在外层使用 `<nav>`。
- 默认名称是英文常量,不随 locale 自动本地化;需要本地化时显式传入 `aria-label`。
- 最后一项自动附加 `aria-current="page"`,并以 `role="link"`、`aria-disabled="true"`、`tabindex="-1"` 的 `span` 呈现,不可 Tab 聚焦或激活。
- 带 `href` 的可导航非当前项使用原生 `a`,支持标准 Tab、Enter 与浏览器链接行为;未提供 `href` 的非当前项、禁用的非当前项与当前项均以 `span[role="link"]` 呈现。禁用/当前项带 `aria-disabled="true"`、`tabindex="-1"`,不保留 `href`,点击被拦截;未禁用的无 `href` 项保留 `tabindex="0"`。RAC 的禁用 span 省略 `tabindex`,Vue Link 保留 `-1` 供程序化聚焦,两者都不能通过 Tab 聚焦。
- 分隔符默认标记为 `aria-hidden="true"` 与 `role="presentation"`,不进入可访问名称。
## 相关组件
[Link 链接](./link) · [Separator 分隔符](./separator)
+100
View File
@@ -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)
+193
View File
@@ -0,0 +1,193 @@
---
title: Typography 排版
description: 面向标题、正文与行内代码的语义化排版原语。
component: typography
group: 组件
---
## 用法
```vue
<script setup lang="ts">
import { Typography } from "@heroui-vue/components";
</script>
<template>
<Typography type="h1">Heading</Typography>
</template>
```
<ComponentPreview name="typography-default" />
> 示例中的 `pnpm add @heroui/react` 沿用固定基线文案;本 Vue 项目的实际包名与安装命令以[安装指南](../guide)为准。
## 组件结构
默认情况下,`Typography` 会将视觉上的 `type` 映射到对应的语义化元素。
```vue
<script setup lang="ts">
import { Typography } from "@heroui-vue/components";
</script>
<template>
<Typography type="h1">Heading</Typography>
</template>
```
| `type` | 默认元素 |
| ---------------------------- | ----------- |
| `h1` – `h6` | `h1` – `h6` |
| `body`、`body-sm`、`body-xs` | `p` |
| `code` | `code` |
需要保留视觉类型但更换语义元素时,使用 `as`。它对应上游的 `render` 自定义渲染能力。
```vue
<Typography type="h1" as="h2">H1 视觉样式,h2 语义元素</Typography>
```
## 示例
### 层级
<ComponentPreview name="typography-typography-scale" />
### 原语
<ComponentPreview name="typography-primitives" />
- `TypographyHeading` 将 `level`(1–6)映射为 `type="h1"` 至 `type="h6"`。
- `TypographyParagraph` 将 `size="base" | "sm" | "xs"` 映射为正文样式。
- `TypographyCode` 映射为行内代码样式。
- `TypographyProse` 为以常规 HTML 子节点传入的富文本内容提供排版样式。
上游以 `Typography.Heading`、`Typography.Paragraph`、`Typography.Code` 和
`Typography.Prose` 对象属性提供这些原语;Vue 版按本库约定改为独立具名导出。
### 富文本排版
<ComponentPreview name="typography-prose" />
### 渲染属性
<ComponentPreview name="typography-render-props" />
React 的 `render` 由 Vue 的 `as` 属性替代,只更换实际渲染元素,不改变
`type` 对应的视觉样式与 `data-type`。
## 自定义样式
### Tailwind CSS
<ComponentPreview name="typography-custom-styles" />
### 全局 CSS
若要自定义 Typography 组件类,可使用 `@layer components` 指令。
```css
@layer components {
.hv-typography--h1 {
@apply font-extrabold tracking-tight;
}
.hv-typography--code {
@apply rounded-md bg-default-100 font-mono dark:bg-default-50/20;
}
}
```
## 样式参考
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
### CSS 类
Typography 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/typography.css)):
#### 基础类 [!toc]
- `.hv-typography` - 排版基础原语
- `.hv-typography-prose` - 富文本文章体容器
#### 类型类 [!toc]
- `.hv-typography--h1` 至 `.hv-typography--h6`
- `.hv-typography--body`、`.hv-typography--body-sm`、`.hv-typography--body-xs`
- `.hv-typography--code`
#### 修饰类 [!toc]
- `.hv-typography--align-start`、`.hv-typography--align-center`、`.hv-typography--align-end`、`.hv-typography--align-justify`
- `.hv-typography--color-default`、`.hv-typography--color-muted`
- `.hv-typography--truncate`
- `.hv-typography--weight-normal`、`.hv-typography--weight-medium`、`.hv-typography--weight-semibold`、`.hv-typography--weight-bold`
## API 参考
### Typography
| 属性 | 类型 | 默认值 | 说明 |
| ---------- | -------------------------------------------------------------------------------------------- | -------------- | ----------------------------------------- |
| `type` | `'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6' \| 'body' \| 'body-sm' \| 'body-xs' \| 'code'` | `'body'` | 语义化排版样式与默认元素。 |
| `align` | `'start' \| 'center' \| 'end' \| 'justify'` | `'start'` | 文本对齐。 |
| `color` | `'default' \| 'muted'` | `'default'` | 文本颜色。 |
| `weight` | `'normal' \| 'medium' \| 'semibold' \| 'bold'` | - | 字重覆盖。 |
| `truncate` | `boolean` | `false` | 将文本截断为单行并显示省略号。 |
| `as` | `string` | 由 `type` 决定 | 自定义实际渲染的元素;替代上游 `render`。 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定)。 |
| 默认插槽 | - | - | 文本内容。 |
`$attrs`(`aria-*`、`data-*`、`id`、`style`、事件等)透传至实际根元素。组件不修改传入内容,也没有内部值或事件。
### TypographyHeading
| 属性 | 类型 | 默认值 | 说明 |
| ---------- | ---------------------------------------------- | --------------- | ----------------------------------- |
| `level` | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | `1` | 映射到 `h1` – `h6` 与对应视觉样式。 |
| `align` | `'start' \| 'center' \| 'end' \| 'justify'` | `'start'` | 文本对齐。 |
| `color` | `'default' \| 'muted'` | `'default'` | 文本颜色。 |
| `weight` | `'normal' \| 'medium' \| 'semibold' \| 'bold'` | - | 字重覆盖。 |
| `truncate` | `boolean` | `false` | 单行截断。 |
| `as` | `string` | 由 `level` 决定 | 自定义实际渲染的元素。 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类。 |
| 默认插槽 | - | - | 标题内容。 |
### TypographyParagraph
| 属性 | 类型 | 默认值 | 说明 |
| ---------- | ---------------------------------------------- | ----------- | ------------------------------------- |
| `size` | `'base' \| 'sm' \| 'xs'` | `'base'` | 映射到 `body`、`body-sm`、`body-xs`。 |
| `align` | `'start' \| 'center' \| 'end' \| 'justify'` | `'start'` | 文本对齐。 |
| `color` | `'default' \| 'muted'` | `'default'` | 文本颜色。 |
| `weight` | `'normal' \| 'medium' \| 'semibold' \| 'bold'` | - | 字重覆盖。 |
| `truncate` | `boolean` | `false` | 单行截断。 |
| `as` | `string` | `'p'` | 自定义实际渲染的元素。 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类。 |
| 默认插槽 | - | - | 正文内容。 |
### TypographyCode
| 属性 | 类型 | 默认值 | 说明 |
| ---------- | ---------------------------------------------- | ----------- | ---------------------- |
| `align` | `'start' \| 'center' \| 'end' \| 'justify'` | `'start'` | 文本对齐。 |
| `color` | `'default' \| 'muted'` | `'default'` | 文本颜色。 |
| `weight` | `'normal' \| 'medium' \| 'semibold' \| 'bold'` | - | 字重覆盖。 |
| `truncate` | `boolean` | `false` | 单行截断。 |
| `as` | `string` | `'code'` | 自定义实际渲染的元素。 |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类。 |
| 默认插槽 | - | - | 行内代码内容。 |
### TypographyProse
| 属性 | 类型 | 默认值 | 说明 |
| -------- | --------------------------- | ------ | ---------------------- |
| `class` | `string \| Array \| Object` | - | 附加 CSS 类。 |
| 默认插槽 | - | - | 常规 HTML 富文本内容。 |
`TypographyProse` 固定渲染 `div`,内部标题、段落、列表、引用、代码块、链接、图片等使用基线排版规则。`$attrs` 透传至该 `div`。
## 相关组件
[Card 卡片](./card) · [Kbd 键盘按键](./kbd)
+12
View File
@@ -0,0 +1,12 @@
<script setup lang="ts">
import { Breadcrumbs, BreadcrumbsItem } from "@heroui-vue/components";
</script>
<template>
<Breadcrumbs>
<BreadcrumbsItem href="#">首页</BreadcrumbsItem>
<BreadcrumbsItem href="#">产品</BreadcrumbsItem>
<BreadcrumbsItem href="#">电子产品</BreadcrumbsItem>
<BreadcrumbsItem>笔记本电脑</BreadcrumbsItem>
</Breadcrumbs>
</template>
@@ -0,0 +1,16 @@
<script setup lang="ts">
import { Breadcrumbs, BreadcrumbsItem } from "@heroui-vue/components";
import { IconCaretRightFilled } from "@tabler/icons-vue";
</script>
<template>
<Breadcrumbs>
<template #separator>
<IconCaretRightFilled aria-hidden="true" :size="12" />
</template>
<BreadcrumbsItem href="#">首页</BreadcrumbsItem>
<BreadcrumbsItem href="#">产品</BreadcrumbsItem>
<BreadcrumbsItem href="#">电子产品</BreadcrumbsItem>
<BreadcrumbsItem>笔记本电脑</BreadcrumbsItem>
</Breadcrumbs>
</template>
@@ -0,0 +1,17 @@
<script setup lang="ts">
import { Breadcrumbs, BreadcrumbsItem } from "@heroui-vue/components";
</script>
<template>
<Breadcrumbs class="rounded-lg bg-default-soft px-3 py-2">
<BreadcrumbsItem class="text-muted hover:text-accent" href="#">
首页
</BreadcrumbsItem>
<BreadcrumbsItem class="text-muted hover:text-accent" href="#">
产品
</BreadcrumbsItem>
<BreadcrumbsItem class="font-medium text-foreground">
笔记本电脑
</BreadcrumbsItem>
</Breadcrumbs>
</template>
+12
View File
@@ -0,0 +1,12 @@
<script setup lang="ts">
import { Breadcrumbs, BreadcrumbsItem } from "@heroui-vue/components";
</script>
<template>
<Breadcrumbs is-disabled>
<BreadcrumbsItem href="#">首页</BreadcrumbsItem>
<BreadcrumbsItem href="#">产品</BreadcrumbsItem>
<BreadcrumbsItem href="#">电子产品</BreadcrumbsItem>
<BreadcrumbsItem>笔记本电脑</BreadcrumbsItem>
</Breadcrumbs>
</template>
+10
View File
@@ -0,0 +1,10 @@
<script setup lang="ts">
import { Breadcrumbs, BreadcrumbsItem } from "@heroui-vue/components";
</script>
<template>
<Breadcrumbs>
<BreadcrumbsItem href="#">首页</BreadcrumbsItem>
<BreadcrumbsItem>当前页面</BreadcrumbsItem>
</Breadcrumbs>
</template>
+11
View File
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { Breadcrumbs, BreadcrumbsItem } from "@heroui-vue/components";
</script>
<template>
<Breadcrumbs>
<BreadcrumbsItem href="#">首页</BreadcrumbsItem>
<BreadcrumbsItem href="#">分类</BreadcrumbsItem>
<BreadcrumbsItem>当前页面</BreadcrumbsItem>
</Breadcrumbs>
</template>
@@ -0,0 +1,12 @@
<script setup lang="ts">
import { Breadcrumbs, BreadcrumbsItem } from "@heroui-vue/components";
</script>
<template>
<Breadcrumbs data-custom="foo">
<BreadcrumbsItem data-custom="bar">首页</BreadcrumbsItem>
<BreadcrumbsItem data-custom="bar">产品</BreadcrumbsItem>
<BreadcrumbsItem data-custom="bar">电子产品</BreadcrumbsItem>
<BreadcrumbsItem data-custom="bar">笔记本电脑</BreadcrumbsItem>
</Breadcrumbs>
</template>
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { ref } from "vue";
import { Button, EmptyState } from "@heroui-vue/components";
const showMessage = ref(true);
</script>
<template>
<div class="flex w-full max-w-md flex-col gap-3">
<div class="rounded-xl border border-border p-4">
<EmptyState>
<span v-if="showMessage">没有找到匹配的结果。</span>
</EmptyState>
</div>
<Button
class="self-start"
size="sm"
variant="secondary"
@click="showMessage = !showMessage"
>
切换内容
</Button>
</div>
</template>
@@ -0,0 +1,9 @@
<script setup lang="ts">
import { EmptyState } from "@heroui-vue/components";
</script>
<template>
<div class="w-full max-w-md rounded-xl border border-border p-4">
<EmptyState>没有找到匹配的搜索结果。</EmptyState>
</div>
</template>
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { EmptyState } from "@heroui-vue/components";
</script>
<template>
<EmptyState
class="w-full max-w-md rounded-xl border border-border bg-surface-secondary p-6 text-center"
>
尚未添加任何项目。
</EmptyState>
</template>
+9
View File
@@ -0,0 +1,9 @@
<script setup lang="ts">
import { EmptyState } from "@heroui-vue/components";
</script>
<template>
<div class="w-full max-w-md rounded-xl border border-border p-4">
<EmptyState />
</div>
</template>
@@ -0,0 +1,22 @@
<script setup lang="ts">
import { Typography } from "@heroui-vue/components";
</script>
<template>
<div
class="flex max-w-md flex-col gap-2 rounded-xl border border-border/80 bg-surface-secondary p-4"
>
<Typography
class="text-xs font-medium tracking-wide text-accent uppercase"
type="body-xs"
>
更新日志
</Typography>
<Typography class="font-semibold tracking-tight text-foreground" type="h4">
更快的搜索结果
</Typography>
<Typography class="text-sm leading-relaxed text-muted" type="body-sm">
得益于改进的索引,查询现在在 200 毫秒内返回。
</Typography>
</div>
</template>
+19
View File
@@ -0,0 +1,19 @@
<script setup lang="ts">
import { Typography } from "@heroui-vue/components";
</script>
<template>
<div class="flex max-w-xl flex-col gap-4">
<Typography type="h1">打造更出色的界面</Typography>
<Typography type="h2">保持语义化的排版</Typography>
<Typography type="h3">默认可组合</Typography>
<Typography type="h4">小标题</Typography>
<Typography>
HeroUI Typography 提供语义化排版类型与 as 元素多态。
</Typography>
<Typography color="muted" type="body-sm">
用于次要说明的较小弱化正文。
</Typography>
<Typography type="code">pnpm add @heroui/react</Typography>
</div>
</template>
+21
View File
@@ -0,0 +1,21 @@
<script setup lang="ts">
import {
TypographyCode,
TypographyHeading,
TypographyParagraph,
} from "@heroui-vue/components";
</script>
<template>
<div class="flex max-w-xl flex-col gap-4">
<TypographyHeading :level="1">仪表盘</TypographyHeading>
<TypographyParagraph>
便捷原语是 Typography
的薄封装,可在不学习第二套样式系统的情况下选择显式组合。
</TypographyParagraph>
<TypographyParagraph color="muted" size="sm">
Paragraph 支持 base、sm 和 xs 尺寸。
</TypographyParagraph>
<TypographyCode>TypographyCode</TypographyCode>
</div>
</template>
+16
View File
@@ -0,0 +1,16 @@
<script setup lang="ts">
import { TypographyProse } from "@heroui-vue/components";
</script>
<template>
<TypographyProse class="flex max-w-xl flex-col gap-3">
<h1>正文标题</h1>
<p>Prose 适用于标记已是语义化、由 HeroUI 应用默认排版节奏的写作型内容。</p>
<h2>章节标题</h2>
<p>
行内代码如
<code>as</code>
与 Typography 原语获得相同的代码样式处理。
</p>
</TypographyProse>
</template>
@@ -0,0 +1,12 @@
<script setup lang="ts">
import { Typography } from "@heroui-vue/components";
</script>
<template>
<div class="flex max-w-xl flex-col gap-4">
<Typography type="h1" as="h2">H1 视觉样式,h2 语义元素</Typography>
<Typography as="span">
as 属性可更换底层元素,同时保留 HeroUI 的 props 与样式。
</Typography>
</div>
</template>
@@ -0,0 +1,84 @@
<script setup lang="ts">
import { Typography } from "@heroui-vue/components";
const scale = [
{
label: "h1",
meta: "36px / 600 / 1.11 / tight",
sample: "打造更出色的界面",
type: "h1",
},
{
label: "h2",
meta: "30px / 600 / 1.17 / tight",
sample: "为智能时代而生",
type: "h2",
},
{
label: "h3",
meta: "24px / 600 / 1.25 / tight",
sample: "按您的条件定价",
type: "h3",
},
{
label: "h4",
meta: "20px / 600 / 1.33 / tight",
sample: "申请创业计划",
type: "h4",
},
{
label: "h5",
meta: "18px / 600 / 1.39 / tight",
sample: "卡片标题",
type: "h5",
},
{
label: "h6",
meta: "16px / 600 / 1.50 / tight",
sample: "较小的功能标题",
type: "h6",
},
{
label: "body",
meta: "16px / 400 / 1.75",
sample: "用于文档、营销文案与描述的主要正文。",
type: "body",
},
{
label: "body-sm",
meta: "14px / 400 / 1.50",
sample: "次要正文、表格单元格、导航与侧边栏项。",
type: "body-sm",
},
{
label: "body-xs",
meta: "12px / 400 / 1.25",
sample: "说明文字、徽章、辅助文本与细则。",
type: "body-xs",
},
{
label: "code",
meta: "14px / mono",
sample: "pnpm add @heroui/react",
type: "code",
},
] as const;
</script>
<template>
<div class="flex w-full flex-col divide-y divide-border">
<div
v-for="row in scale"
:key="row.label"
class="grid grid-cols-[160px_1fr] items-center gap-8 py-5"
>
<div class="flex shrink-0 flex-col gap-0.5">
<span class="text-sm font-semibold text-foreground">
{{ row.label }}
</span>
<span class="text-xs whitespace-nowrap text-muted">{{ row.meta }}</span>
</div>
<Typography :type="row.type">{{ row.sample }}</Typography>
</div>
</div>
</template>