Files
maoyingjie 145a208687 docs: close documentation facts, structure and related-component mapping
HD-04 scope, against heroui ce90ea3 cn sources:

- stale/fictional content: input.md no longer claims TextField is
  unmigrated; color-field.md no longer claims ColorPicker is private;
  header.md drops the fictional Header.Root subcomponent and the stale
  'menus not migrated' wording (MenuSection label registration is now
  documented from HeaderRoot source); radio-group.md drops three copied
  CheckboxGroup wordings (variant override is Radio's, scalar emits,
  native single-value submit); input-otp.md drops the fictional
  data-complete state and lists the real missing upstream props
- toggle-button disabled row now matches the real CSS hooks
  (:disabled / [aria-disabled], with data-disabled as a marker only)
- part API / CSS classes / interactive states restored per pinned
  sources: button (full class lists + real variable-based global CSS),
  accordion (per-part tables + variant/state lists), card (per-part
  tables + variant list), switch (SwitchGroup snippet + Switch/
  SwitchGroup class lists + states), color-field Group (class list +
  states), input-otp (variant notes, global CSS, class/state lists);
  input-group gains the two upstream usage chapters
- RelatedComponents restored from the pinned componentRelationships
  (first-3, filtered against componentsMap): 64 pages rewritten,
  list-box/slider sections added, 7 empty-mapping pages' fabricated
  entries removed; RelatedShowcases left unmigrated with its real data
  inventory recorded (2 cases, showcase-site cards)
- defaults unified on implementation evidence: granularity (inferred
  day/minute) and visibleYears (full min-max span, no "or 20" fallback);
  HD-03 hand-offs resolved (trigger focus-visible noted for HD-06,
  width guards kept)
- new demos: header-collection-grouping (MenuSection/ListBoxSection
  label wiring), empty-state-collection (collection empty slot);
  empty-state page deduplicated with a boundary compatibility note
- ComponentPreview minHeight/isBgSolid restored per the 30 upstream
  marks; tabs-overflow max-w-full kept after measuring internal scroll
- tests: +3 header registration/demo cases, +1 empty-state collection
  case; full suite 110 files / 1630 tests, typecheck and build:docs
  pass
2026-10-28 22:32:10 +08:00

106 lines
3.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
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` 适配。
## 相关组件
[Card 卡片](./card) · [Chip 标签](./chip) · [Avatar 头像](./avatar)