JGuang

卡片

Card · Ant Design Mobile

交互预览
npm install antd-mobile@5.43.0

卡片 Card

通用卡片容器。

安装

npm install antd-mobile@5.43.0

antd-mobile 是移动网页组件库,不是 React Native 或小程序组件。React 19 项目需在入口用 unstableSetRender 注册 createRoot,否则 Toast、Dialog 等命令式 API 无法渲染;深色模式通过 <html data-prefers-color-scheme="dark"> 切换。

示例来自 Ant Design Mobile 官方仓库(MIT),固定在 npm 5.43.0 对应的提交;示例中的 DemoBlock 等展示辅助组件由 JGuang 重写,不属于 antd-mobile 的 API。

通用卡片容器。

何时使用

可承载文字、列表、图片、段落等,便于用户浏览内容。

示例

Card

属性

属性说明类型默认值版本
bodyClassNamebody 自定义类名string-
bodyStylebody 自定义样式React.CSSProperties-
extraheader 右边区域ReactNode-
headerClassNameheader 自定义类名string-
headerStyleheader 自定义样式React.CSSProperties-
iconheader 左边图标ReactNode-5.38.0
onBodyClickbody 区域点击事件(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void-
onClick卡片点击事件(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void-
onHeaderClickheader 区域点击事件(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void-
titleheader 左边区域ReactNode-

CSS 变量

属性说明默认值全局变量版本
--adm-card-border-radius圆角大小8px--adm-card-border-radius
--adm-card-padding-inline水平内边距12px--adm-card-padding-inline
--adm-card-header-border-widthheader 分割线宽度0.5px--adm-card-header-border-width
--adm-card-header-border-colorheader 分割线颜色var(--adm-color-border)--adm-card-header-border-color
--adm-card-header-gapheader 水平间隙8px--adm-card-header-gap5.38.0
--adm-card-header-padding-blockheader 垂直内边距12px--adm-card-header-padding-block
--adm-card-body-padding-blockbody 垂直内边距12px--adm-card-body-padding-block