Back to Ant Design

Card

components/card/index.en-US.md

6.3.74.3 KB
Original Source

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

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">Basic card</code> <code src="./demo/border-less.tsx" background="grey">No border</code> <code src="./demo/simple.tsx">Simple card</code> <code src="./demo/flexible-content.tsx">Customized content</code> <code src="./demo/in-column.tsx" background="grey">Card in column</code> <code src="./demo/loading.tsx">Loading card</code> <code src="./demo/grid-card.tsx">Grid card</code> <code src="./demo/inner.tsx">Inner card</code> <code src="./demo/tabs.tsx">With tabs</code> <code src="./demo/meta.tsx">Support more content configuration</code> <code src="./demo/style-class.tsx" version="6.0.0">Custom semantic dom styling</code> <code src="./demo/no-body-debug.tsx" debug>Cover and actions without body</code> <code src="./demo/component-token.tsx" debug>Component Token</code>

API

Common props ref:Common props

jsx
<Card title="Card title">Card content</Card>
PropertyDescriptionTypeDefaultVersion
actionsThe action list, shows at the bottom of the CardArray<ReactNode>-
activeTabKeyCurrent TabPane's keystring-
borderedToggles rendering of the border around the card, please use variant insteadbooleantrue
bodyStyleStyle of card body, please use styles.body insteadCSSProperties--
variantVariants of Cardoutlined | borderless |outlined5.24.0
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
coverCard coverReactNode-
defaultActiveTabKeyInitial active TabPane's key, if activeTabKey is not setstringThe key of first tab
extraContent to render in the top-right corner of the cardReactNode-
hoverableLift up when hovering cardbooleanfalse
headStyleStyle of card head, please use styles.header insteadCSSProperties--
loadingShows a loading indicator while the contents of the card are being fetchedbooleanfalse
sizeSize of cardmedium | smallmedium
tabBarExtraContentExtra content in tab barReactNode-
tabListList of TabPane's headTabItemType[]-
tabPropsTabs--
titleCard titleReactNode-
typeCard style type, can be set to inner or not setstring-
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-
onTabChangeCallback when tab is switched(key) => void-

Card.Grid

PropertyDescriptionTypeDefaultVersion
classNameThe className of containerstring-
hoverableLift up when hovering card gridbooleantrue
styleThe style object of containerCSSProperties-

Card.Meta

PropertyDescriptionTypeDefaultVersion
avatarAvatar or iconReactNode-
classNameThe className of containerstring-
descriptionDescription contentReactNode-
styleThe style object of containerCSSProperties-
titleTitle contentReactNode-

Semantic DOM

Card

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

Card.Meta

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

Design Token

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