Card
A container for displaying information.
When To Use
A card can be used to display content related to a single subject. The content can consist of multiple elements of varying types and sizes.
Examples
- Basic card ·
basic - No border ·
border-less - Simple card ·
simple - Customized content ·
flexible-content - Card in column ·
in-column - Loading card ·
loading - Grid card ·
grid-card - Inner card ·
inner - With tabs ·
tabs - Support more content configuration ·
meta - Custom semantic dom styling ·
style-class
API
Common props ref:Common props
<Card title="Card title">Card content</Card>
| Property | Description | Type | Default | Version | Global Config |
|---|---|---|---|---|---|
| actions | The action list, shows at the bottom of the Card | Array<ReactNode> | - | × | |
| activeTabKey | Current TabPane's key | string | - | × | |
Toggles rendering of the border around the card, please use variant instead | boolean | true | × | ||
Style of card body, please use styles.body instead | CSSProperties | - | - | × | |
| variant | Variants of Card | outlined | borderless | outlined | 5.24.0 | 5.24.0 |
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string> | - | 5.14.0 | |
| cover | Card cover | ReactNode | - | × | |
| defaultActiveTabKey | Initial active TabPane's key, if activeTabKey is not set | string | The key of first tab | × | |
| extra | Content to render in the top-right corner of the card | ReactNode | - | × | |
| hoverable | Lift up when hovering card | boolean | false | × | |
Style of card head, please use styles.header instead | CSSProperties | - | - | × | |
| loading | Shows a loading indicator while the contents of the card are being fetched | boolean | false | × | |
| size | Size of card | medium | small | medium | × | |
| tabBarExtraContent | Extra content in tab bar | ReactNode | - | × | |
| tabList | List of TabPane's head | TabItemType[] | - | × | |
| tabProps | Tabs | - | - | × | |
| title | Card title | ReactNode | - | × | |
| type | Card style type, can be set to inner or not set | string | - | × | |
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties> | - | 5.14.0 | |
| onTabChange | Callback when tab is switched | (key) => void | - | × |
Card.Grid
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| hoverable | Lift up when hovering card grid | boolean | true |
Card.Meta
| Property | Description | Type | Default | Version | Global Config |
|---|---|---|---|---|---|
| avatar | Avatar or icon | ReactNode | - | × | |
| description | Description content | ReactNode | - | × | |
| title | Title content | ReactNode | - | × |
Semantic DOM
Card
| Semantic node | Native description | Version |
|---|---|---|
root | Card root element with positioning, background, border, border-radius, box-shadow, padding and other container styles | 6.0.0 |
header | Card header area with flex layout, min-height, padding, text color, font-weight, font-size, background, bottom border and top border-radius | 5.14.0 |
title | Card title with inline-block display, flex-grow, text ellipsis and other title display styles | 5.14.0 |
extra | Card extra operation area in top-right corner with text color and layout styles for additional content | 5.14.0 |
cover | Title cover with styles for cover image display and layout | 5.14.0 |
body | Card content area with padding, font-size and other content display styles | 5.14.0 |
actions | Card bottom action group with flex layout, list-style reset, background, top border and bottom border-radius for action buttons container | 5.14.0 |
Semantic description source: vendor/components/card/demo/_semantic.tsx
Card.Meta
| Semantic node | Native description | Version |
|---|---|---|
root | set root of Card.Meta | 6.0.0 |
section | set section of Card.Meta | 6.0.0 |
avatar | set avatar of Card.Meta | 6.0.0 |
title | set title of Card.Meta | 6.0.0 |
description | set description of Card.Meta | 6.0.0 |
Semantic description source: vendor/components/card/demo/_semantic_meta.tsx
Design Token
Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.
| Token | Type | Native description |
|---|---|---|
headerBg | string | Background color of card header |
headerFontSize | number | string | Font size of card header |
headerFontSizeSM | number | string | Font size of small card header |
headerHeight | number | string | Height of card header |
headerHeightSM | number | string | Height of small card header |
bodyPaddingSM | number | Padding of small card body |
headerPaddingSM | number | Padding of small card head |
bodyPadding | number | Padding of card body |
headerPadding | number | Padding of card head |
actionsBg | string | Background color of card actions |
actionsLiMargin | string | Margin of each item in card actions |
tabsMarginBottom | number | Margin bottom of tabs component |
extraColor | string | Text color of extra area |
Declaration source: vendor/components/card/style/index.ts
import { unit } from '@ant-design/cssinjs';
import type { CSSObject } from '@ant-design/cssinjs';
import { clearFix, resetComponent, textEllipsis } from '../../style';
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
import { genStyleHooks, mergeToken } from '../../theme/internal';
export interface ComponentToken {
/**
* @desc 卡片头部背景色
* @descEN Background color of card header
*/
headerBg: string;
/**
* @desc 卡片头部文字大小
* @descEN Font size of card header
*/
headerFontSize: number | string;
/**
* @desc 小号卡片头部文字大小
* @descEN Font size of small card header
*/
headerFontSizeSM: number | string;
/**
* @desc 卡片头部高度
* @descEN Height of card header
*/
headerHeight: number | string;
/**
* @desc 小号卡片头部高度
* @descEN Height of small card header
*/
headerHeightSM: number | string;
/**
* @desc 小号卡片内边距
* @descEN Padding of small card body
*/
bodyPaddingSM: number;
/**
* @desc 小号卡片头部内边距
* @descEN Padding of small card head
*/
headerPaddingSM: number;
/**
* @desc 卡片内边距
* @descEN Padding of card body
*/
bodyPadding: number;
/**
* @desc 卡片头部内边距
* @descEN Padding of card head
*/
headerPadding: number;
/**
* @desc 操作区背景色
* @descEN Background color of card actions
*/
actionsBg: string;
/**
* @desc 操作区每一项的外间距
* @descEN Margin of each item in card actions
*/
actionsLiMargin: string;
/**
* @desc 内置标签页组件下间距
* @descEN Margin bottom of tabs component
*/
tabsMarginBottom: number;
/**
* @desc 额外区文字颜色
* @descEN Text color of extra area
*/
extraColor: string;
}
interface CardToken extends FullToken<'Card'> {
/**
* @desc 卡片阴影
* @descEN Shadow of card
*/
cardShadow: string;
/**
* @desc 卡片头部内边距
* @descEN Padding of card header
*/
cardHeadPadding: number;
/**
* @desc 卡片基础内边距
* @descEN Padding of base card
*/
cardPaddingBase: number;
/**
* @desc 卡片操作区图标大小
* @descEN Size of card actions icon
*/
cardActionsIconSize: number;
}
Shared native props
Tips: The following generic properties apply to most antd components; those not supported are described separately.
| Property | Description | Type | Default |
|---|---|---|---|
| style | The additional style | CSSProperties | - |
| className | The additional css class | string | - |
| rootClassName | ClassName on the root element | string | - |
| autoFocus | Auto focus when component mounted, only effective for focusable elements like forms, links, etc. | boolean | false |
Install and reproduce an example
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23
Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.
Native type references
The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.
vendor/components/card/Card.tsxvendor/components/card/CardGrid.tsxvendor/components/card/CardMeta.tsxvendor/components/card/index.tsxvendor/components/card/style/index.ts
Source and license
https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd
Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.