feat: add Separator Kbd and Chip components
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
---
|
||||
title: Chip 标签
|
||||
description: 用于显示标签、状态与分类的小型信息徽章
|
||||
component: chip
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Chip } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="chip-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
> 纯文本子节点会自动包裹在 `<ChipLabel>` 中。
|
||||
|
||||
```vue
|
||||
<Chip>
|
||||
Label text
|
||||
</Chip>
|
||||
```
|
||||
|
||||
显式使用部件或组合内容时不会重复包装:
|
||||
|
||||
```vue
|
||||
<Chip>
|
||||
<IconCircleFilled :size="6" aria-hidden="true" />
|
||||
<ChipLabel>标签</ChipLabel>
|
||||
</Chip>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
<ComponentPreview name="chip-variants" />
|
||||
|
||||
### 状态类型
|
||||
|
||||
<ComponentPreview name="chip-statuses" />
|
||||
|
||||
### 带图标
|
||||
|
||||
<ComponentPreview name="chip-with-icon" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="chip-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
可使用 `@layer components` 指令自定义 Chip 组件类。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-chip {
|
||||
@apply rounded-full text-xs;
|
||||
}
|
||||
|
||||
.hv-chip__label {
|
||||
@apply font-medium;
|
||||
}
|
||||
|
||||
.hv-chip--accent {
|
||||
@apply border-accent/20;
|
||||
}
|
||||
|
||||
.hv-chip--accent .hv-chip__label {
|
||||
@apply text-accent;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Chip 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/chip.css)):
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-chip` - 基础标签容器样式
|
||||
- `.hv-chip__label` - 标签文本 slot 样式
|
||||
|
||||
#### 颜色类 [!toc]
|
||||
|
||||
- `.hv-chip--accent` - 强调色变体
|
||||
- `.hv-chip--danger` - 危险色变体
|
||||
- `.hv-chip--default` - 默认色变体
|
||||
- `.hv-chip--success` - 成功色变体
|
||||
- `.hv-chip--warning` - 警告色变体
|
||||
|
||||
#### 变体类 [!toc]
|
||||
|
||||
- `.hv-chip--primary` - 填充背景的主变体
|
||||
- `.hv-chip--secondary` - 带边框的次变体
|
||||
- `.hv-chip--tertiary` - 透明背景的三级变体
|
||||
- `.hv-chip--soft` - 浅色背景的 soft 变体
|
||||
|
||||
#### 尺寸类 [!toc]
|
||||
|
||||
- `.hv-chip--sm` - 小尺寸
|
||||
- `.hv-chip--md` - 中尺寸(默认)
|
||||
- `.hv-chip--lg` - 大尺寸
|
||||
|
||||
#### 复合变体类 [!toc]
|
||||
|
||||
Chip 支持组合变体与颜色类(如 `.hv-chip--secondary.hv-chip--accent`)。以下组合有默认样式:
|
||||
|
||||
**Primary Variants:**
|
||||
|
||||
- `.hv-chip--primary.hv-chip--accent` - 填充背景的 primary accent 组合
|
||||
- `.hv-chip--primary.hv-chip--success` - 填充背景的 primary success 组合
|
||||
- `.hv-chip--primary.hv-chip--warning` - 填充背景的 primary warning 组合
|
||||
- `.hv-chip--primary.hv-chip--danger` - 填充背景的 primary danger 组合
|
||||
|
||||
**Soft Variants:**
|
||||
|
||||
- `.hv-chip--accent.hv-chip--soft` - 浅色背景的 soft accent 组合
|
||||
- `.hv-chip--success.hv-chip--soft` - 浅色背景的 soft success 组合
|
||||
- `.hv-chip--warning.hv-chip--soft` - 浅色背景的 soft warning 组合
|
||||
- `.hv-chip--danger.hv-chip--soft` - 浅色背景的 soft danger 组合
|
||||
|
||||
**Note:** 可使用 CSS 中的 `@layer components` 指令为任意变体-颜色组合(如 `.hv-chip--secondary.hv-chip--accent`、`.hv-chip--tertiary.hv-chip--success`)应用自定义样式。
|
||||
|
||||
## API 参考
|
||||
|
||||
### Chip
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------- | ------------------------------------------------------------- | ------------- | --------------------------------------------------- |
|
||||
| `color` | `'default' \| 'accent' \| 'success' \| 'warning' \| 'danger'` | `'default'` | 标签颜色变体 |
|
||||
| `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'soft'` | `'secondary'` | 视觉样式变体 |
|
||||
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | 标签尺寸 |
|
||||
| 默认插槽 | `Component` | - | 标签内显示的内容;纯文本/数字自动包装为 `ChipLabel` |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
### ChipLabel
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| -------- | --------------------------- | ------ | ----------------------------- |
|
||||
| 默认插槽 | `Component` | - | 标签文本内容 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
`class` 遵循 Vue 的 class 绑定,可接收字符串、数组和对象,并与组件或 slot 基础类合并;不要使用 React 的 `className`。
|
||||
|
||||
纯文本或数字默认插槽会在渲染时包装为 `ChipLabel`;显式 `ChipLabel` 或图标等组合内容不会重复包装。文本与组合内容之间动态切换时会按当前插槽重新判断。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Card 卡片](./card) · [Avatar 头像](./avatar)
|
||||
@@ -0,0 +1,142 @@
|
||||
---
|
||||
title: Kbd 键盘按键
|
||||
description: 展示键盘快捷键与按键组合
|
||||
component: kbd
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Kbd, KbdAbbr, KbdContent } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="kbd-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Kbd, KbdAbbr, KbdContent } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Kbd>
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>K</KbdContent>
|
||||
</Kbd>
|
||||
</template>
|
||||
```
|
||||
|
||||
`KbdAbbr` 根据 `keyValue` 显示按键符号,并自动设置无障碍 `title`。`KbdContent` 包裹按键字母或文本。
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
<ComponentPreview name="kbd-variants" />
|
||||
|
||||
### 导航按键
|
||||
|
||||
<ComponentPreview name="kbd-navigation-keys" />
|
||||
|
||||
### 行内用法
|
||||
|
||||
<ComponentPreview name="kbd-inline-usage" />
|
||||
|
||||
### 说明文字
|
||||
|
||||
<ComponentPreview name="kbd-instructional-text" />
|
||||
|
||||
### 特殊按键
|
||||
|
||||
<ComponentPreview name="kbd-special-keys" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="kbd-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
可使用 `@layer components` 指令自定义 Kbd 组件类。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-kbd {
|
||||
@apply bg-gray-100 dark:bg-gray-800 border-gray-300;
|
||||
}
|
||||
|
||||
.hv-kbd__abbr {
|
||||
@apply font-bold;
|
||||
}
|
||||
|
||||
.hv-kbd__content {
|
||||
@apply text-sm;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Kbd 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/kbd.css)):
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-kbd` - 基础按键样式,含背景、边框与间距
|
||||
- `.hv-kbd__abbr` - 修饰键的缩写元素
|
||||
- `.hv-kbd__content` - 按键文本的内容包裹层
|
||||
|
||||
## API 参考
|
||||
|
||||
### Kbd
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| --------- | --------------------------- | ----------- | ----------------------------- |
|
||||
| `variant` | `'default' \| 'light'` | `'default'` | 按键视觉变体 |
|
||||
| 默认插槽 | `Component` | - | 按键内容 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
### KbdAbbr
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ---------- | --------------------------- | ------ | --------------------------------------------------------------------------- |
|
||||
| `keyValue` | `KbdKey` | - | 要显示的按键;符号与 `title` 由映射表给出(如 `command` → `⌘` / `Command`) |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
### KbdContent
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| -------- | --------------------------- | ------ | ----------------------------- |
|
||||
| 默认插槽 | `Component` | - | 按键文本内容 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
`class` 遵循 Vue 的 class 绑定,可接收字符串、数组和对象,并与对应 slot 的基础类合并;不要使用 React 的 `className`。
|
||||
|
||||
### KbdContent Type
|
||||
|
||||
`keyValue` prop 可用的按键值:
|
||||
|
||||
| Modifier Keys | Special Keys | Navigation Keys | Function Keys |
|
||||
| ------------- | ------------ | --------------- | ------------- |
|
||||
| `command` | `enter` | `up` | `fn` |
|
||||
| `shift` | `delete` | `down` | |
|
||||
| `ctrl` | `escape` | `left` | |
|
||||
| `option` | `tab` | `right` | |
|
||||
| `alt` | `space` | `pageup` | |
|
||||
| `win` | `capslock` | `pagedown` | |
|
||||
| | `help` | `home` | |
|
||||
| | | `end` | |
|
||||
|
||||
上游文档表格曾写作 `Kbd.Key` 与 `title`/`children`;实际实现与全部演示使用 `KbdAbbr` 的 `keyValue` 与 `KbdContent`。本库按实现迁移,并同时导出 `kbdKeysMap`、`kbdKeysLabelMap` 与 `KbdKey` 类型。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Button 按钮](./button) · [Link 链接](./link)
|
||||
@@ -0,0 +1,105 @@
|
||||
---
|
||||
title: Separator 分隔符
|
||||
description: 在内容区块之间进行视觉分隔。
|
||||
component: separator
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Separator } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
|
||||
<ComponentPreview name="separator-basic" />
|
||||
|
||||
## 示例
|
||||
|
||||
### 变体
|
||||
|
||||
<ComponentPreview name="separator-variants" />
|
||||
|
||||
### 与 Surface 组合
|
||||
|
||||
Separator 组件会根据不同的表面背景自动适配,以获得更好的可见性。
|
||||
|
||||
<ComponentPreview name="separator-with-surface" />
|
||||
|
||||
### 垂直方向
|
||||
|
||||
<ComponentPreview name="separator-vertical" />
|
||||
|
||||
### 带内容
|
||||
|
||||
<ComponentPreview name="separator-with-content" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
Vue 使用 `as-child` 将分隔符属性合并到默认插槽中唯一的自定义根元素,对应上游 `render` 函数示例,不将 render prop 原样搬入 Vue。
|
||||
|
||||
<ComponentPreview name="separator-render-function" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="separator-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
若要自定义组件类,可使用 `@layer components` 指令。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-separator {
|
||||
@apply bg-accent h-[2px];
|
||||
}
|
||||
|
||||
.hv-separator--vertical {
|
||||
@apply bg-accent w-[2px];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
|
||||
|
||||
### CSS 类
|
||||
|
||||
Separator 使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/separator.css)):
|
||||
|
||||
#### 基础类与方向类 [!toc]
|
||||
|
||||
- `.hv-separator` - 基础 Separator 样式,默认水平方向
|
||||
- `.hv-separator--horizontal` - 水平方向(全宽,高度 1px)
|
||||
- `.hv-separator--vertical` - 垂直方向(全高,宽度 1px)
|
||||
|
||||
#### 变体类 [!toc]
|
||||
|
||||
- `.hv-separator--default` - 默认变体,标准对比度
|
||||
- `.hv-separator--secondary` - 次要变体,中等对比度
|
||||
- `.hv-separator--tertiary` - 第三级变体,较弱对比度
|
||||
|
||||
## API 参考
|
||||
|
||||
### Separator
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------- | ---------------------------------------- | -------------- | -------------------------------- |
|
||||
| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Separator 的方向 |
|
||||
| `variant` | `'default' \| 'secondary' \| 'tertiary'` | `'default'` | Separator 的视觉变体 |
|
||||
| `decorative` | `boolean` | `false` | 装饰性分隔线,使用 `role="none"` |
|
||||
| `as` | `string` | `'hr'` | 自定义根元素标签 |
|
||||
| `asChild` | `boolean` | `false` | 将属性合并到默认插槽唯一根元素 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
|
||||
`class` 遵循 Vue 的 class 绑定,可接收字符串、数组和对象,并与组件基础类合并;不要使用 React 的 `className`。
|
||||
|
||||
默认渲染为 `hr`,带 `role="separator"` 与 `data-orientation`。`orientation` 为 `vertical` 时附加 `aria-orientation="vertical"`。上游 `render` 由 `as-child` 适配。
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Surface 表面](./surface) · [Card 卡片](./card)
|
||||
Reference in New Issue
Block a user