# 卡片 (/zh/components/cards)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 2241 · updated: 2026-07-30 -->
Related: [折叠面板](/zh/components/accordions.md), [徽章](/zh/components/badge.md), [横幅](/zh/components/banner.md), [标注框](/zh/components/callouts.md), [代码分组](/zh/components/code-groups.md), [颜色](/zh/components/color.md)

使用卡片为内容创建可视化容器。卡片是一种灵活的容器，可以包含文本、图标、图片和链接。

<div id="basic-card">
  ## 基础卡片 [#基础卡片]
</div>

<Card title="卡片标题" icon="<svg xmlns=&#x22;http://www.w3.org/2000/svg&#x22; viewBox=&#x22;0 0 24 24&#x22; fill=&#x22;none&#x22;><path d=&#x22;M9 4.5H19&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M9 9.5H14&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M9 14.5H19&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M9 19.5H14&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M5 3V21&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/></svg>" href="/zh/components/columns">
  这是带有图标和链接的卡片用法。点击此卡片
  将跳转到 Columns 页面。
</Card>

```mdx title="Card example"
<Card title="卡片标题" icon="text-align-start" href="/zh/components/columns">
  这是使用带有图标和链接的卡片的示例。点击此卡片会跳转到列组件页面。
</Card>
```

<div id="card-variations">
  ## 卡片样式变体 [#卡片样式变体]
</div>

卡片支持多种布局和样式选项，可满足不同的内容需求。

<div id="horizontal-layout">
  ### 水平布局 [#水平布局]
</div>

添加 `horizontal` 属性，以更紧凑的水平布局显示卡片。

<Card title="水平卡片" icon="<svg xmlns=&#x22;http://www.w3.org/2000/svg&#x22; viewBox=&#x22;0 0 24 24&#x22; fill=&#x22;none&#x22;><path d=&#x22;M9 4.5H19&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M9 9.5H14&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M9 14.5H19&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M9 19.5H14&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M5 3V21&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/></svg>">
  这是一个水平卡片示例。
</Card>

```mdx title="Horizontal card example"
<Card title="横向卡片" icon="text-align-start" horizontal>
  这是横向卡片的示例。
</Card>
```

<div id="image-cards">
  ### 图片卡片 [#图片卡片]
</div>

添加一个 `img` 属性即可在卡片顶部显示图片。

<Card title="图片卡片" img="https://mintlify-assets.b-cdn.net/yosemite.jpg">
  这是一个带图片的卡片示例。
</Card>

```mdx title="Image card example"
<Card title="图片卡片" img="/images/card-with-image.png">
  这是一个带图片的卡片示例。
</Card>
```

<div id="link-cards-with-custom-ctas">
  ### 带有自定义 CTA 的链接卡片 [#带有自定义-cta-的链接卡片]
</div>

你可以自定义号召性用语的文本，并控制是否显示箭头。默认情况下，箭头只会显示在外部链接上。

<Card title="链接卡片" icon="<svg xmlns=&#x22;http://www.w3.org/2000/svg&#x22; viewBox=&#x22;0 0 24 24&#x22; fill=&#x22;none&#x22;><path d=&#x22;M9.14339 10.691L9.35031 10.4841C11.329 8.50532 14.5372 8.50532 16.5159 10.4841C18.4947 12.4628 18.4947 15.671 16.5159 17.6497L13.6497 20.5159C11.671 22.4947 8.46279 22.4947 6.48405 20.5159C4.50532 18.5372 4.50532 15.329 6.48405 13.3503L6.9484 12.886&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M17.0516 11.114L17.5159 10.6497C19.4947 8.67095 19.4947 5.46279 17.5159 3.48405C15.5372 1.50532 12.329 1.50532 10.3503 3.48405L7.48405 6.35031C5.50532 8.32904 5.50532 11.5372 7.48405 13.5159C9.46279 15.4947 12.671 15.4947 14.6497 13.5159L14.8566 13.309&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/></svg>" href="/zh/components/columns" arrow="true" cta="点击这里">
  这是一个带有图标和链接的卡片示例。点击此卡片会将你带到 Columns 页面。
</Card>

```mdx title="Link card example"
<Card
  title="链接卡片"
  icon="link"
  href="/zh/components/columns"
  arrow="true"
  cta="点击这里"
>
  这是一个带有图标和链接的卡片示例。点击此卡片可跳转到列组件页面。
</Card>
```

<div id="typed-cards">
  ### 类型化卡片 [#类型化卡片]
</div>

添加 `type` 属性，可以让卡片应用与 [callout](/zh/components/callouts) 相同的主题样式。类型化卡片会带有与所选类型相匹配的彩色背景、边框和默认图标。使用它们来突出显示分组内容，例如说明、警告或成功状态。

支持的类型：`info`、`warning`、`note`、`tip`、`check` 和 `danger`。你也可以使用 `icon` 属性覆盖默认图标。

<Columns cols="2">
  <Card title="说明卡片" type="note">
    使用 `note` 来突出显示补充信息。
  </Card>

  <Card title="警告卡片" type="warning">
    使用 `warning` 来标记潜在问题。
  </Card>

  <Card title="提示卡片" type="tip">
    使用 `tip` 来分享有用的建议。
  </Card>

  <Card title="危险卡片" type="danger">
    使用 `danger` 来表示破坏性或有风险的操作。
  </Card>
</Columns>

```mdx title="Typed card example"
<Card title="说明卡片" type="note">
  使用 `note` 来突出显示补充信息。
</Card>

<Card title="警告卡片" type="warning">
  使用 `warning` 来标记潜在问题。
</Card>
```

<div id="group-cards">
  ## 分组卡片 [#分组卡片]
</div>

使用 [Columns 组件](/zh/components/columns) 将多个卡片并排展示。Columns 组件支持 1 到 4 列，并会自动适配小屏幕。

<Columns cols="2">
  <Card title="第一张卡片" icon="<svg xmlns=&#x22;http://www.w3.org/2000/svg&#x22; viewBox=&#x22;0 0 24 24&#x22; fill=&#x22;none&#x22;><path d=&#x22;M21 11C21 7.22876 21 5.34315 19.8284 4.17157C18.6569 3 16.7712 3 13 3H11C7.22876 3 5.34315 3 4.17157 4.17157C3 5.34315 3 7.22876 3 11V13C3 16.7712 3 18.6569 4.17157 19.8284C5.34315 21 7.22876 21 11 21H13C16.7712 21 18.6569 21 19.8284 19.8284C21 18.6569 21 16.7712 21 13V11Z&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M9 3V21&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M14 9L15.1082 9.87868C16.3694 10.8787 17 11.3787 17 12C17 12.6213 16.3694 13.1213 15.1082 14.1213L14 15&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/></svg>">
    这是第一张卡片。
  </Card>

  <Card title="第二张卡片" icon="<svg xmlns=&#x22;http://www.w3.org/2000/svg&#x22; viewBox=&#x22;0 0 24 24&#x22; fill=&#x22;none&#x22;><path d=&#x22;M3 11C3 7.22876 3 5.34315 4.17157 4.17157C5.34315 3 7.22876 3 11 3H13C16.7712 3 18.6569 3 19.8284 4.17157C21 5.34315 21 7.22876 21 11V13C21 16.7712 21 18.6569 19.8284 19.8284C18.6569 21 16.7712 21 13 21H11C7.22876 21 5.34315 21 4.17157 19.8284C3 18.6569 3 16.7712 3 13V11Z&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M15 3V21&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/><path d=&#x22;M8 9L9.10819 9.87868C10.3694 10.8787 11 11.3787 11 12C11 12.6213 10.3694 13.1213 9.10819 14.1213L8 15&#x22; stroke=&#x22;currentColor&#x22; stroke-linecap=&#x22;round&#x22; stroke-linejoin=&#x22;round&#x22; stroke-width=&#x22;1.5&#x22;/></svg>">
    这是第二张卡片。
  </Card>
</Columns>

```mdx title="Columns example"
<Columns cols={2}>
  <Card title="第一张卡片" icon="panel-left-close">
    这是第一张卡片。
  </Card>
  <Card title="第二张卡片" icon="panel-right-close">
    这是第二张卡片。
  </Card>
</Columns>
```

<div id="properties">
  ## 属性 [#属性]
</div>

<ResponseField name="title" type="string">
  显示在卡片上的标题。
</ResponseField>

<ResponseField name="icon" type="string">
  要显示的图标。

  可选值：

  * [Font Awesome](https://fontawesome.com/icons) 图标名称 (如果你在 `docs.json` 中将 `icons.library` [属性](/zh/organize/settings#param-icons) 设置为 `fontawesome`)
  * [Lucide](https://lucide.dev/icons) 图标名称 (如果你在 `docs.json` 中将 `icons.library` [属性](/zh/organize/settings#param-icons) 设置为 `lucide`)
  * [Tabler](https://tabler.io/icons) 图标名称 (如果你在 `docs.json` 中将 `icons.library` [属性](/zh/organize/settings#param-icons) 设置为 `tabler`)
  * 指向外部托管图标的 URL
  * 项目中图标文件的路径
  * 用花括号包裹的 SVG 代码

  对于自定义 SVG 图标：

  1. 使用 [SVGR 转换器](https://react-svgr.com/playground/) 转换你的 SVG。
  2. 将 SVG 代码粘贴到 SVG 输入框。
  3. 从 JSX 输出框中复制完整的 `<svg>...</svg>` 元素。
  4. 用花括号包裹可用于 JSX 的 SVG 代码：`icon={<svg ...> ... </svg>}`。
  5. 根据需要调整 `height` 和 `width`。
</ResponseField>

<ResponseField name="iconType" type="string">
  [Font Awesome](https://fontawesome.com/icons) 的图标样式。仅在使用 Font Awesome 图标时生效。

  可选值：`regular`、`solid`、`light`、`thin`、`sharp-solid`、`duotone`、`brands`。
</ResponseField>

<ResponseField name="color" type="string">
  图标颜色，使用十六进制色值 (例如 `#FF6B6B`) 。
</ResponseField>

<ResponseField name="href" type="string">
  卡片被点击时跳转到的 URL。
</ResponseField>

<ResponseField name="horizontal" type="boolean">
  以紧凑的横向布局显示卡片。
</ResponseField>

<ResponseField name="img" type="string">
  在卡片顶部显示的图片 URL 或本地路径。
</ResponseField>

<ResponseField name="cta" type="string">
  操作按钮的自定义文本。
</ResponseField>

<ResponseField name="arrow" type="boolean">
  是否显示链接箭头图标。
</ResponseField>

<ResponseField name="type" type="string">
  为卡片应用 callout 风格的主题。可选值为 `info`、`warning`、`note`、`tip`、`check` 或 `danger`。会将卡片的背景、边框和默认图标设置为与所选类型相匹配。
</ResponseField>
