2016-05-26 17:46:55 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
2022-11-09 12:28:04 +08:00
|
|
|
|
group: Data Display
|
2016-05-26 17:46:55 +08:00
|
|
|
|
title: Card
|
2024-03-22 14:22:42 +08:00
|
|
|
|
description: A container for displaying information.
|
2024-01-29 14:50:36 +08:00
|
|
|
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*QXO1SKEdIzYAAAAAAAAAAAAADrJ8AQ/original
|
|
|
|
|
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*5WDvQp_H7LUAAAAAAAAAAAAADrJ8AQ/original
|
2016-05-26 17:46:55 +08:00
|
|
|
|
---
|
|
|
|
|
|
2016-09-10 13:43:30 +08:00
|
|
|
|
## When To Use
|
2016-05-26 17:46:55 +08:00
|
|
|
|
|
2017-09-16 11:28:18 +08:00
|
|
|
|
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.
|
2016-05-26 17:46:55 +08:00
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
|
## Examples
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<code src="./demo/basic.tsx">Basic card</code>
|
2023-01-05 15:30:59 +08:00
|
|
|
|
<code src="./demo/border-less.tsx" background="grey">No border</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<code src="./demo/simple.tsx">Simple card</code>
|
|
|
|
|
<code src="./demo/flexible-content.tsx">Customized content</code>
|
2023-01-05 15:30:59 +08:00
|
|
|
|
<code src="./demo/in-column.tsx" background="grey">Card in column</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<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>
|
2023-06-01 15:16:58 +08:00
|
|
|
|
<code src="./demo/component-token.tsx" debug>Component Token</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
2016-05-26 17:46:55 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2023-08-08 18:27:48 +08:00
|
|
|
|
Common props ref:[Common props](/docs/react/common-props)
|
|
|
|
|
|
2019-12-26 14:37:39 +08:00
|
|
|
|
```jsx
|
2016-05-26 17:46:55 +08:00
|
|
|
|
<Card title="Card title">Card content</Card>
|
|
|
|
|
```
|
|
|
|
|
|
2017-07-07 13:36:54 +08:00
|
|
|
|
### Card
|
|
|
|
|
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
2020-07-01 22:15:26 +08:00
|
|
|
|
| actions | The action list, shows at the bottom of the Card | Array<ReactNode> | - | |
|
2019-11-20 20:31:43 +08:00
|
|
|
|
| activeTabKey | Current TabPane's key | string | - | |
|
2020-06-17 23:18:14 +08:00
|
|
|
|
| bordered | Toggles rendering of the border around the card | boolean | true | |
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| cover | Card cover | ReactNode | - | |
|
2020-07-01 22:15:26 +08:00
|
|
|
|
| defaultActiveTabKey | Initial active TabPane's key, if `activeTabKey` is not set | string | - | |
|
2020-10-09 10:08:52 +08:00
|
|
|
|
| extra | Content to render in the top-right corner of the card | ReactNode | - | |
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| hoverable | Lift up when hovering card | boolean | false | |
|
|
|
|
|
| loading | Shows a loading indicator while the contents of the card are being fetched | boolean | false | |
|
2019-11-20 20:31:43 +08:00
|
|
|
|
| size | Size of card | `default` \| `small` | `default` | |
|
2020-10-21 10:33:43 +08:00
|
|
|
|
| tabBarExtraContent | Extra content in tab bar | ReactNode | - | |
|
2023-05-16 22:24:41 +08:00
|
|
|
|
| tabList | List of TabPane's head | [TabItemType](/components/tabs#tabitemtype)[] | - | |
|
2022-12-22 14:12:26 +08:00
|
|
|
|
| tabProps | [Tabs](/components/tabs/#tabs) | - | - | |
|
2020-10-09 10:08:52 +08:00
|
|
|
|
| title | Card title | ReactNode | - | |
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| type | Card style type, can be set to `inner` or not set | string | - | |
|
2024-01-30 15:00:25 +08:00
|
|
|
|
| classNames | Config Card build-in module's className | Record<SemanticDOM, string> | - | 5.14.0 |
|
|
|
|
|
| styles | Config Card build-in module's style | Record<SemanticDOM, string> | - | 5.14.0 |
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| onTabChange | Callback when tab is switched | (key) => void | - | |
|
2017-07-07 13:36:54 +08:00
|
|
|
|
|
|
|
|
|
### Card.Grid
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
|
| --------- | ------------------------------- | ------------- | ------- | ------- |
|
|
|
|
|
| className | The className of container | string | - | |
|
|
|
|
|
| hoverable | Lift up when hovering card grid | boolean | true | |
|
|
|
|
|
| style | The style object of container | CSSProperties | - | |
|
2017-08-09 14:34:10 +08:00
|
|
|
|
|
|
|
|
|
### Card.Meta
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
|
| ----------- | ----------------------------- | ------------- | ------- | ------- |
|
|
|
|
|
| avatar | Avatar or icon | ReactNode | - | |
|
|
|
|
|
| className | The className of container | string | - | |
|
|
|
|
|
| description | Description content | ReactNode | - | |
|
|
|
|
|
| style | The style object of container | CSSProperties | - | |
|
|
|
|
|
| title | Title content | ReactNode | - | |
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
2024-01-30 15:00:25 +08:00
|
|
|
|
### `styles` 和 `classNames` attribute
|
|
|
|
|
|
|
|
|
|
| 名称 | 说明 | 版本 |
|
|
|
|
|
| ------- | --------------------- | ------ |
|
|
|
|
|
| header | set `header` of card | 5.14.0 |
|
|
|
|
|
| body | set `body` of card | 5.14.0 |
|
|
|
|
|
| extra | set `extra` of card | 5.14.0 |
|
|
|
|
|
| title | set `title` of card | 5.14.0 |
|
|
|
|
|
| actions | set `actions` of card | 5.14.0 |
|
|
|
|
|
| cover | set `cover` of card | 5.14.0 |
|
|
|
|
|
|
2023-04-11 10:25:24 +08:00
|
|
|
|
## Design Token
|
|
|
|
|
|
|
|
|
|
<ComponentTokenTable component="Card"></ComponentTokenTable>
|