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

基础卡片

Card title

这是使用带有图标和链接的卡片的方法。点击此卡片 将跳转到 Columns 页面。
Card example
<Card title="Card title" icon="text" href="/components/columns">
  This is how you use a card with an icon and a link. Clicking on this card
  brings you to the Columns page.
</Card>

卡片变体

卡片提供多种布局和样式选项,可满足不同内容需求。

水平布局

添加 horizontal 属性,以更紧凑的水平布局展示卡片。

Horizontal card

这是一个水平卡片的示例。
Horizontal card example
<Card title="Horizontal card" icon="text" horizontal>
  This is an example of a horizontal card.
</Card>

图片卡片

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

图片卡片

这是一个带图片的卡片示例。
Image card example
<Card title="Image card" img="/images/card-with-image.png">
  This is an example of a card with an image.
</Card>
你可以自定义号召性用语(CTA)文本,并控制是否显示箭头。默认情况下,箭头仅在外部链接上显示。

Link card

这是一个带有图标和链接的卡片示例。点击此卡片会跳转到 Columns 页面。
Link card example
<Card
  title="Link card"
  icon="link"
  href="/components/columns"
  arrow="true"
  cta="Click here"
>
  {/* 这是一个带有图标和链接的卡片示例。点击此卡片会跳转到 Columns 页面。 */}
</Card>

分组卡片

使用 Columns 组件 将多个卡片并排排列。

First card

这是第一张卡片。

Second card

这是第二张卡片。
Columns example
<Columns cols={2}>
  <Card title="First card" icon="panel-left-close">
    This is the first card.
  </Card>
  <Card title="Second card" icon="panel-right-close">
    This is the second card.
  </Card>
</Columns>

属性

title
string
required
卡片上显示的标题
icon
string
要显示的图标。可选值:
  • Font Awesome 图标 的名称
  • Lucide 图标 的名称
  • 用花括号包裹的、与 JSX 兼容的 SVG 代码
  • 指向外部托管图标的 URL
  • 项目中图标文件的路径
自定义 SVG 图标:
  1. 使用 SVGR 转换器将 SVG 转换。
  2. 将 SVG 代码粘贴到 SVG 输入框。
  3. 从 JSX 输出框复制完整的 <svg>...</svg> 元素。
  4. 用花括号包裹 JSX 兼容的 SVG 代码:icon={<svg ...> ... </svg>}
  5. 按需调整 heightwidth
iconType
string
Font Awesome 图标样式。仅在使用 Font Awesome 图标时使用。可选值:regularsolidlightthinsharp-solidduotonebrands
color
string
图标颜色,使用十六进制色值(例如 #FF6B6B)。
href
string
点击卡片时跳转到的 URL。
horizontal
boolean
以紧凑的横向布局显示卡片。
img
string
显示在卡片顶部的图片的 URL 或本地路径。
cta
string
操作按钮的自定义文案。
arrow
boolean
显示或隐藏链接箭头图标。