Card
Simple rectangular container.
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
Card title
Card content
Card content
Card content
import { Card } from 'antd';
ReactDOM.render(
<Card title="Card title" extra={<a href="#">More</a>} style={{ width: 300 }}>
<p>Card content</p>
<p>Card content</p>
<p>Card content</p>
</Card>
, mountNode);
Card title
Card content
Card content
Card content
import { Card } from 'antd';
ReactDOM.render(
<div style={{ background: '#ECECEC', padding: '30px' }}>
<Card title="Card title" bordered={false} style={{ width: 300 }}>
<p>Card content</p>
<p>Card content</p>
<p>Card content</p>
</Card>
</div>
, mountNode);
Card content
Card content
Card content
import { Card } from 'antd';
ReactDOM.render(
<Card style={{ width: 300 }}>
<p>Card content</p>
<p>Card content</p>
<p>Card content</p>
</Card>
, mountNode);
import { Card } from 'antd';
const { Meta } = Card;
ReactDOM.render(
<Card
hoverable
style={{ width: 240 }}
cover={<img alt="example" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" />}
>
<Meta
title="Europe Street beat"
description="www.instagram.com"
/>
</Card>
, mountNode);
Card title
Card content
Card title
Card content
Card title
Card content
import { Card, Col, Row } from 'antd';
ReactDOM.render(
<div style={{ background: '#ECECEC', padding: '30px' }}>
<Row gutter={16}>
<Col span={8}>
<Card title="Card title" bordered={false}>Card content</Card>
</Col>
<Col span={8}>
<Card title="Card title" bordered={false}>Card content</Card>
</Col>
<Col span={8}>
<Card title="Card title" bordered={false}>Card content</Card>
</Col>
</Row>
</div>
, mountNode);
Card title
import { Card } from 'antd';
ReactDOM.render(
<Card loading title="Card title" style={{ width: '34%' }}>
Whatever content
</Card>
, mountNode);
Card Title
Content
Content
Content
Content
Content
Content
Content
import { Card } from 'antd';
const gridStyle = {
width: '25%',
textAlign: 'center',
};
ReactDOM.render(
<Card title="Card Title">
<Card.Grid style={gridStyle}>Content</Card.Grid>
<Card.Grid style={gridStyle}>Content</Card.Grid>
<Card.Grid style={gridStyle}>Content</Card.Grid>
<Card.Grid style={gridStyle}>Content</Card.Grid>
<Card.Grid style={gridStyle}>Content</Card.Grid>
<Card.Grid style={gridStyle}>Content</Card.Grid>
<Card.Grid style={gridStyle}>Content</Card.Grid>
</Card>
, mountNode);
import { Card } from 'antd';
ReactDOM.render(
<Card title="Card title">
<p
style={{
fontSize: 14,
color: 'rgba(0, 0, 0, 0.85)',
marginBottom: 16,
fontWeight: 500,
}}
>
Group title
</p>
<Card
type="inner"
title="Inner Card title"
extra={<a href="#">More</a>}
>
Inner Card content
</Card>
<Card
style={{ marginTop: 16 }}
type="inner"
title="Inner Card title"
extra={<a href="#">More</a>}
>
Inner Card content
</Card>
</Card>
, mountNode);
import { Card } from 'antd';
const tabList = [{
key: 'tab1',
tab: 'tab1',
}, {
key: 'tab2',
tab: 'tab2',
}];
const contentList = {
tab1: <p>content1</p>,
tab2: <p>content2</p>,
};
const tabListNoTitle = [{
key: 'article',
tab: 'article',
}, {
key: 'app',
tab: 'app',
}, {
key: 'project',
tab: 'project',
}];
const contentListNoTitle = {
article: <p>article content</p>,
app: <p>app content</p>,
project: <p>project content</p>,
};
class TabsCard extends React.Component {
state = {
key: 'tab1',
noTitleKey: 'app',
}
onTabChange = (key, type) => {
console.log(key, type);
this.setState({ [type]: key });
}
render() {
return (
<div>
<Card
style={{ width: '100%' }}
title="Card title"
extra={<a href="#">More</a>}
tabList={tabList}
onTabChange={(key) => { this.onTabChange(key, 'key'); }}
>
{contentList[this.state.key]}
</Card>
<br /><br />
<Card
style={{ width: '100%' }}
tabList={tabListNoTitle}
activeTabKey={this.state.noTitleKey}
onTabChange={(key) => { this.onTabChange(key, 'noTitleKey'); }}
>
{contentListNoTitle[this.state.noTitleKey]}
</Card>
</div>
);
}
}
ReactDOM.render(
<TabsCard />
, mountNode);
import { Card, Icon, Avatar } from 'antd';
const { Meta } = Card;
ReactDOM.render(
<Card
style={{ width: 300 }}
cover={<img alt="example" src="https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png" />}
actions={[<Icon type="setting" />, <Icon type="edit" />, <Icon type="ellipsis" />]}
>
<Meta
avatar={<Avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />}
title="Card title"
description="This is the description"
/>
</Card>
, mountNode);
API#
<Card title="Card title">Card content</Card>
Card#
Property | Description | Type | Default |
---|---|---|---|
actions | The action list, shows at the bottom of the Card. | Array | - |
bodyStyle | Inline style to apply to the card content | object | - |
bordered | Toggles rendering of the border around the card | boolean | true |
cover | Card cover | ReactNode | - |
extra | Content to render in the top-right corner of the card | string|ReactNode | - |
hoverable | Lift up when hovering card | boolean | false |
loading | Shows a loading indicator while the contents of the card are being fetched | boolean | false |
tabList | List of TabPane's head. | Array<{key: string, tab: ReactNode}> | - |
activeTabKey | Current TabPane's key | string | - |
defaultActiveTabKey | Initial active TabPane's key, if activeTabKey is not set. | string | - |
title | Card title | string|ReactNode | - |
type | Card style type, can be set to inner or not set | string | - |
onTabChange | Callback when tab is switched | (key) => void | - |
Card.Grid#
Property | Description | Type | Default |
---|---|---|---|
className | className of container | string | - |
style | style object of container | object | - |
Card.Meta#
Property | Description | Type | Default |
---|---|---|---|
avatar | avatar or icon | ReactNode | - |
className | className of container | string | - |
description | description content | ReactNode | - |
style | style object of container | object | - |
title | title content | ReactNode | - |