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

2.8 KiB
Raw Permalink Blame History

title, description, component, group
title description component group
Surface 表面 提供表面级样式与子组件上下文的容器组件 surface 组件

用法

<script setup lang="ts">
import { Surface } from "@heroui-vue/components";
</script>

示例

变体

Surface 提供描述 prominence 层级的语义变体:

  • default - 标准表面外观(bg-surface)
  • secondary - 中等 prominence(bg-surface-secondary)
  • tertiary - 较高 prominence(bg-surface-tertiary)
  • transparent - 透明背景,适用于遮罩层和自定义背景

搭配表单

在 Surface 内使用表单组件时,请使用 variant="secondary" 以应用适合表面背景的低强调变体。

自定义样式

Tailwind CSS

全局 CSS

若要自定义组件类,可使用 @layer components 指令。

@layer components {
  .hv-surface {
    @apply rounded-2xl border border-border;
  }

  .hv-surface--secondary {
    @apply bg-gradient-to-br from-blue-50 to-purple-50;
  }
}

样式参考

HeroUI 遵循 BEM 方法论,确保组件变体与状态可复用且易于自定义。

CSS 类

Surface 组件使用以下 CSS 类:

基础类 [!toc]

  • .hv-surface - Surface 根容器

变体类 [!toc]

  • .hv-surface--default - 默认 Surface 变体(bg-surface)
  • .hv-surface--secondary - Secondary Surface 变体(bg-surface-secondary)
  • .hv-surface--tertiary - Tertiary Surface 变体(bg-surface-tertiary)
  • .hv-surface--transparent - 透明 Surface 变体

API 参考

Surface

Prop 类型 默认值 描述
variant "transparent" | "default" | "secondary" | "tertiary" "default" Surface 的视觉变体。
class string - 额外的 CSS 类。

默认插槽渲染 Surface 内容。其他属性与 DOM 事件透传到根 div。

Context API

surfaceContextKey

子组件可通过 Surface 上下文读取当前变体:

<script setup lang="ts">
import { inject } from "vue";
import { surfaceContextKey } from "@heroui-vue/components";

const surface = inject(surfaceContextKey, undefined);
// surface.variant.value 为 "transparent" | "default" | "secondary" | "tertiary"
</script>

相关组件

CheckboxGroup 复选框组 · Fieldset 字段组 · InputOTP 验证码输入