Files
heroui-vue/apps/docs/components/card.md
T
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

4.2 KiB
Raw Blame History

title, description, component, group
title description component group
Card 卡片 灵活容器组件,用于分组相关内容与操作 card 组件

用法

<script setup lang="ts">
import {
  Card,
  CardHeader,
  CardTitle,
  CardDescription,
  CardContent,
  CardFooter,
} from "@heroui-vue/components";
</script>
## 组件结构
<Card>
  <CardHeader>
    <CardTitle />
    <CardDescription />
  </CardHeader>
  <CardContent />
  <CardFooter />
</Card>

示例

变体

Card 提供语义变体,描述 prominence 级别而非具体视觉样式,允许主题以不同方式解读:

  • transparent:透明背景,无阴影,适合嵌套卡片。
  • default:标准卡片,使用 --surface。
  • secondary:使用 --surface-secondary。
  • tertiary:使用 --surface-tertiary。

基线中文说明中的部分表面映射与实际 CSS 不一致;这里以固定提交的 CSS 为准。

水平布局

带头像

带图片

搭配表单

头像使用 Reka Avatar 组合;链接与表单使用原生 HTML,标签与输入显式关联。此示例不发送登录请求;图片沿用上游公开资源地址。

自定义样式

Tailwind CSS

全局 CSS

@layer components {
  .hv-card__title {
    font-weight: 700;
  }
}

样式参考

部件 CSS 类 data-slot 默认元素
Card .hv-card card div
CardHeader .hv-card__header card-header div
CardTitle .hv-card__title card-title h3
CardDescription .hv-card__description card-description p
CardContent .hv-card__content card-content div
CardFooter .hv-card__footer card-footer div

变体类 [!toc]

  • .hv-card--transparent - 透明背景、无边框与无阴影(遮罩层与自定义背景场景)
  • .hv-card--default - 默认表面(bg-surface)
  • .hv-card--secondary - 次级表面(bg-surface-secondary)
  • .hv-card--tertiary - 三级表面(bg-surface-tertiary)

API 参考

Card

Prop 类型 默认值 描述
variant 'transparent' | 'default' | 'secondary' | 'tertiary' 'default' 表示 prominence 级别的语义变体
as string 'div' 渲染的 HTML 元素
class string / object / array — Vue 标准类名合并

CardHeader / CardTitle / CardDescription / CardContent / CardFooter

属性 类型 默认值 描述
as string 见上表默认元素列 渲染的 HTML 元素
class string | Array | Object — 额外的 CSS 类,合并到部件根元素
默认插槽 - - 部件内容;$attrs(ARIA、事件)透传根元素

各部件无业务状态或事件;类名与 data-slot 见样式参考表。Vue 使用独立命名导出替代 Card.Header 等 React 部件访问方式。

无障碍

<Card as="article" aria-labelledby="card-title">
  <CardHeader><CardTitle id="card-title">Article Title</CardTitle></CardHeader>
</Card>

相关组件

Surface 表面 · Avatar 头像 · Form 表单