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
This commit is contained in:
maoyingjie
2026-10-28 22:32:10 +08:00
parent 2c6d871354
commit 145a208687
76 changed files with 912 additions and 352 deletions
+50 -3
View File
@@ -89,21 +89,68 @@ Vue 使用 `asChild` 将按钮属性与交互合并到一个自定义原生 butt
### 全局 CSS
可使用 `@layer components` 指令自定义 Button 组件类;下面的选择器与语义变量都是当前样式表中真实存在的入口:
```css
@layer components {
/* 覆盖变体语义变量 */
.hv-button--primary {
--button-bg: oklch(0.6 0.2 300);
--button-bg-hover: oklch(0.55 0.2 300);
--button-bg-pressed: oklch(0.55 0.2 300);
--button-fg: white;
}
/* 或直接覆盖类规则 */
.hv-button--icon-only {
@apply rounded-lg;
}
}
```
## 样式参考
基础类为 `.hv-button`,变体为 `.hv-button--primary` 等;尺寸为 `.hv-button--sm` / `md` / `lg`。支持 `.hv-button--icon-only` 和 `.hv-button--full-width`。
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
### CSS 类
Button 使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/button.css)):
#### 基础与尺寸类 [!toc]
- `.hv-button` - 基础按钮样式
- `.hv-button--sm` - 小尺寸变体
- `.hv-button--md` - 中尺寸变体(默认)
- `.hv-button--lg` - 大尺寸变体
#### 变体类 [!toc]
- `.hv-button--primary`
- `.hv-button--secondary`
- `.hv-button--tertiary`
- `.hv-button--outline`
- `.hv-button--ghost`
- `.hv-button--danger`
- `.hv-button--danger-soft`
#### 修饰符类 [!toc]
- `.hv-button--icon-only`
- `.hv-button--icon-only.hv-button--sm`
- `.hv-button--icon-only.hv-button--lg`
- `.hv-button--full-width`
### 交互状态
保留 `data-hovered`、`data-pressed`、`data-focused`、`data-focus-visible`、`data-pending` 状态;键盘焦点样式与鼠标焦点区分。加载期间保留焦点并阻止重复点击,通过 aria-disabled 呈现半透明的原变体颜色。
按钮同时支持 CSS 伪类与 data 属性:
- **Hover**:`:hover` 或 `[data-hovered="true"]`
- **Active/Pressed**:`:active` 或 `[data-pressed="true"]`(含缩放变换)
- **Focus**:`:focus-visible` 或 `[data-focus-visible="true"]`(显示焦点环)
- **Disabled**:`:disabled` 或 `[aria-disabled="true"]`(降低透明度,禁用指针事件)
- **Pending**:`[data-pending="true"]`(加载期间禁用指针事件)
加载期间保留焦点并阻止重复点击,通过 `aria-disabled` 呈现半透明的原变体颜色。
## API 参考
@@ -139,4 +186,4 @@ Vue 使用 `@click` 和默认作用域插槽。插槽提供 `isPending`、`isPre
## 相关组件
[Card 卡片](./card) · [Input 输入框](./input) · [Switch 开关](./switch)
[Popover 弹出框](./popover) · [Tooltip 工具提示](./tooltip) · [Form 表单](./form)