2016-03-31 14:17:09 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
2022-11-09 12:28:04 +08:00
|
|
|
|
group: 数据展示
|
2016-05-26 17:46:55 +08:00
|
|
|
|
title: Card
|
|
|
|
|
subtitle: 卡片
|
2024-03-22 14:22:42 +08:00
|
|
|
|
description: 通用卡片容器。
|
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-03-31 14:17:09 +08:00
|
|
|
|
---
|
2016-02-19 19:35:49 +08:00
|
|
|
|
|
|
|
|
|
## 何时使用
|
|
|
|
|
|
|
|
|
|
最基础的卡片容器,可承载文字、列表、图片、段落,常用于后台概览页面。
|
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
|
## 代码演示
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<code src="./demo/basic.tsx">典型卡片</code>
|
2023-01-05 15:30:59 +08:00
|
|
|
|
<code src="./demo/border-less.tsx" background="grey">无边框</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<code src="./demo/simple.tsx">简洁卡片</code>
|
|
|
|
|
<code src="./demo/flexible-content.tsx">更灵活的内容展示</code>
|
2023-01-05 15:30:59 +08:00
|
|
|
|
<code src="./demo/in-column.tsx" background="grey">栅格卡片</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<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>
|
2023-06-01 15:16:58 +08:00
|
|
|
|
<code src="./demo/component-token.tsx" debug>组件 Token</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
2016-02-20 16:40:18 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2023-08-08 18:27:48 +08:00
|
|
|
|
通用属性参考:[通用属性](/docs/react/common-props)
|
|
|
|
|
|
2019-12-26 14:37:39 +08:00
|
|
|
|
```jsx
|
2016-02-19 19:35:49 +08:00
|
|
|
|
<Card title="卡片标题">卡片内容</Card>
|
|
|
|
|
```
|
|
|
|
|
|
2017-07-07 13:36:54 +08:00
|
|
|
|
### Card
|
|
|
|
|
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| actions | 卡片操作组,位置在卡片底部 | Array<ReactNode> | - | |
|
2019-11-20 20:31:43 +08:00
|
|
|
|
| activeTabKey | 当前激活页签的 key | string | - | |
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| bordered | 是否有边框 | boolean | true | |
|
|
|
|
|
| cover | 卡片封面 | ReactNode | - | |
|
2020-06-17 23:18:14 +08:00
|
|
|
|
| defaultActiveTabKey | 初始化选中页签的 key,如果没有设置 activeTabKey | string | `第一个页签` | |
|
2020-10-09 10:08:52 +08:00
|
|
|
|
| extra | 卡片右上角的操作区域 | ReactNode | - | |
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| hoverable | 鼠标移过时可浮起 | boolean | false | |
|
|
|
|
|
| loading | 当卡片内容还在加载中时,可以用 loading 展示一个占位 | boolean | false | |
|
2019-11-20 20:31:43 +08:00
|
|
|
|
| size | card 的尺寸 | `default` \| `small` | `default` | |
|
2020-10-21 10:33:43 +08:00
|
|
|
|
| tabBarExtraContent | tab bar 上额外的元素 | ReactNode | - | |
|
2023-05-16 22:24:41 +08:00
|
|
|
|
| tabList | 页签标题列表 | [TabItemType](/components/tabs#tabitemtype)[] | - | |
|
2022-12-22 14:12:26 +08:00
|
|
|
|
| tabProps | [Tabs](/components/tabs-cn#tabs) | - | - | |
|
2020-10-09 10:08:52 +08:00
|
|
|
|
| title | 卡片标题 | ReactNode | - | |
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| type | 卡片类型,可设置为 `inner` 或 不设置 | string | - | |
|
2024-01-30 15:00:25 +08:00
|
|
|
|
| classNames | 配置卡片内置模块的 className | Record<SemanticDOM, string> | - | 5.14.0 |
|
|
|
|
|
| styles | 配置卡片内置模块的 style | Record<SemanticDOM, string> | - | 5.14.0 |
|
2019-07-11 14:14:33 +08:00
|
|
|
|
| onTabChange | 页签切换的回调 | (key) => void | - | |
|
2017-07-07 13:36:54 +08:00
|
|
|
|
|
|
|
|
|
### Card.Grid
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| --------- | ---------------------- | ------------- | ------ | ---- |
|
|
|
|
|
| className | 网格容器类名 | string | - | |
|
|
|
|
|
| hoverable | 鼠标移过时可浮起 | boolean | true | |
|
|
|
|
|
| style | 定义网格容器类名的样式 | CSSProperties | - | |
|
2017-08-09 14:34:10 +08:00
|
|
|
|
|
|
|
|
|
### Card.Meta
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| ----------- | ------------------ | ------------- | ------ | ---- |
|
|
|
|
|
| avatar | 头像/图标 | ReactNode | - | |
|
|
|
|
|
| className | 容器类名 | string | - | |
|
|
|
|
|
| description | 描述内容 | ReactNode | - | |
|
|
|
|
|
| style | 定义容器类名的样式 | CSSProperties | - | |
|
|
|
|
|
| title | 标题内容 | ReactNode | - | |
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
2024-01-30 15:00:25 +08:00
|
|
|
|
### `styles` 和 `classNames` 属性
|
|
|
|
|
|
|
|
|
|
| 名称 | 说明 | 版本 |
|
|
|
|
|
| ------- | ------------------------ | ------ |
|
|
|
|
|
| header | 设置卡片头部区域 | 5.14.0 |
|
|
|
|
|
| body | 设置卡片内容区域 | 5.14.0 |
|
|
|
|
|
| extra | 设置卡片右上角的操作区域 | 5.14.0 |
|
|
|
|
|
| title | 设置卡片标题 | 5.14.0 |
|
|
|
|
|
| actions | 设置卡片底部操作组 | 5.14.0 |
|
|
|
|
|
| cover | 设置标题封面 | 5.14.0 |
|
|
|
|
|
|
2023-08-30 23:02:35 +08:00
|
|
|
|
## 主题变量(Design Token)
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
|
|
|
|
<ComponentTokenTable component="Card"></ComponentTokenTable>
|