Back to Ant Design

Card

components/card/index.zh-CN.md

6.3.74.2 KB
Original Source

何时使用 {#when-to-use}

最基础的卡片容器,可承载文字、列表、图片、段落,常用于后台概览页面。

代码演示 {#examples}

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">典型卡片</code> <code src="./demo/border-less.tsx" background="grey">无边框</code> <code src="./demo/simple.tsx">简洁卡片</code> <code src="./demo/flexible-content.tsx">更灵活的内容展示</code> <code src="./demo/in-column.tsx" background="grey">栅格卡片</code> <code src="./demo/loading.tsx">预加载的卡片</code> <code src="./demo/grid-card.tsx">网格型内嵌卡片</code> <code src="./demo/inner.tsx">内部卡片</code> <code src="./demo/tabs.tsx">带页签的卡片</code> <code src="./demo/meta.tsx">支持更多内容配置</code> <code src="./demo/style-class.tsx" version="6.0.0">自定义语义结构的样式和类</code> <code src="./demo/no-body-debug.tsx" debug>封面和操作区不渲染 body</code> <code src="./demo/component-token.tsx" debug>组件 Token</code>

API

通用属性参考:通用属性

jsx
<Card title="卡片标题">卡片内容</Card>
参数说明类型默认值版本
actions卡片操作组,位置在卡片底部Array<ReactNode>-
activeTabKey当前激活页签的 keystring-
bordered是否有边框, 请使用 variant 替换booleantrue
bodyStyle卡片内容区域样式,请使用 styles.body 替代CSSProperties--
variant形态变体outlined | borderless |outlined5.24.0
classNames用于自定义组件内部各语义化结构的 class,支持对象或函数Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
cover卡片封面ReactNode-
defaultActiveTabKey初始化选中页签的 key,如果没有设置 activeTabKeystring第一个页签的 key
extra卡片右上角的操作区域ReactNode-
hoverable鼠标移过时可浮起booleanfalse
headStyle卡片头部样式,请使用 styles.header 替代CSSProperties--
loading当卡片内容还在加载中时,可以用 loading 展示一个占位booleanfalse
sizecard 的尺寸medium | smallmedium
tabBarExtraContenttab bar 上额外的元素ReactNode-
tabList页签标题列表TabItemType[]-
tabPropsTabs--
title卡片标题ReactNode-
type卡片类型,可设置为 inner 或 不设置string-
styles用于自定义组件内部各语义化结构的行内 style,支持对象或函数Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-
onTabChange页签切换的回调(key) => void-

Card.Grid

参数说明类型默认值版本
className网格容器类名string-
hoverable鼠标移过时可浮起booleantrue
style定义网格容器类名的样式CSSProperties-

Card.Meta

参数说明类型默认值版本
avatar头像/图标ReactNode-
className容器类名string-
description描述内容ReactNode-
style定义容器类名的样式CSSProperties-
title标题内容ReactNode-

Semantic DOM

Card

<code src="./demo/_semantic.tsx" simplify="true"></code>

Card.Meta

<code src="./demo/_semantic_meta.tsx" simplify="true"></code>

主题变量(Design Token){#design-token}

<ComponentTokenTable component="Card"></ComponentTokenTable>