ProCard
In-page container cards that provide standard card styles, card segmentation and grid layout capabilities. ProCard creatively combines Col, Row, Card, Tabs and other component implementations together, allowing you to complete various card-related layouts with only one component.
- If you also need to use it with the chart, you can refer to the
StatisticCardindicator card component, which is a further package of ProCard. - If you also need to encapsulate
ProCard, note that you need to expose the static property ofisProCard=trueso that ProCard can be recognized as the same element.
When to use
- When a standard card is required to hold the content.
- When multiple card grids are required, gutter layout.
- When in-card split layout is required.
- When the card is required to be foldable.
A basic ProCard reuses the antd Card skin and tokens. When variant is omitted it is passed through to antd Card and follows ConfigProvider card.variant / global variant (same as antd Card)—ProCard does not hard-code a default. card.className / style / classNames / styles are also merged by the underlying Card. Only legacy skins (ghost, checked, boxShadow, etc.) resolve ConfigProvider themselves for the border class.
Code demo
Enum property switch
Switch between size, variant, layout, type, direction, split, and collapsible with Segmented control.
Basic Card
When used alone a ProCard is just a regular card.
Grid layout
When nesting child cards, the component will automatically switch to flex flex box layout, you can set direction to column to specify the flex direction, you can also configure the ghost property to true to remove background color and padding for in-page layout.
ProCard ColSpan 配置 Props 说明:
- direction: 排列方向,'column' 表示垂直排列
- ghost: 是否使用幽灵模式,无背景和边框
- gutter: 间距设置,支持响应式配置
- title: 卡片标题
- style: 卡片样式对象
子卡片配置:
- colSpan: 列跨度,支持多种配置方式
- layout: 布局方式,'center' 表示居中对齐
- variant: 卡片变体样式,'outlined' 表示带边框
ColSpan 配置方式:
- 数字值: colSpan=12 使用 24 栅格系统
- 响应式对象: 根据屏幕尺寸设置不同的列数
- 像素值: colSpan="200px" 固定宽度
- 百分比: colSpan="30%" 相对宽度
- 零值: colSpan=0 隐藏卡片
响应式断点配置:
- xs: 超小屏幕 (<576px)
- sm: 小屏幕 (≥576px)
- md: 中等屏幕 (≥768px)
- lg: 大屏幕 (≥992px)
- xl: 超大屏幕 (≥1200px)
- xxl: 超超大屏幕 (≥1600px)
布局特点:
- 24 栅格系统: 使用数字值时,总列数应该为 24
- 自动宽度: 不设置 colSpan 时自动填充剩余空间
- 固定宽度: 使用像素值时宽度固定不变
- 相对宽度: 使用百分比时宽度随容器变化
- 隐藏卡片: colSpan=0 时卡片完全隐藏
Ghost 模式特点:
- 无背景: 卡片没有背景色
- 无边框: 卡片没有边框
- 透明效果: 适合作为布局容器
使用场景:
- 响应式布局: 构建响应式的卡片网格
- 固定布局: 使用固定宽度构建布局
- 弹性布局: 使用百分比构建弹性布局
- 条件显示: 使用 colSpan=0 条件隐藏卡片
最佳实践:
- 栅格计算: 使用数字值时确保总列数为 24
- 响应式设计: 在不同断点下测试布局效果
- 混合使用: 结合多种配置方式构建复杂布局
Responsive
colSpan supports Grid Responsive Layout defined by antd. There are six preset response sizes: xs sm md lg xl xxl. If you want to support responsiveness, you can write { xs: 4, sm: 8, md: 10, lg: 12 }.
ProCard 响应式布局 Props 说明:
- gutter: 间距设置,数字值表示统一的间距
- title: 卡片标题
- style: 卡片样式对象
子卡片配置:
- colSpan: 响应式栅格列数配置,支持多种格式
- layout: 布局方式,'center' 表示居中对齐
- variant: 卡片变体样式,'outlined' 表示带边框
ColSpan 配置方式:
- 数字值: 如 { xs: 2, sm: 4 },使用 24 栅格系统
- 像素值: 如 { xs: '50px', sm: '100px' } ,固定宽度
- 百分比: 如 { xs: '10%', sm: '20%' }