Skip to content

Card 卡片

用于展示商品的图片、价格等信息。

组件类型

基本使用

通过 title 设置标题,默认插槽传入内容,footer 插槽用于底部操作区。

html
<wd-card title="岳阳楼记">
  <view class="content-text">
    至若春和景明,波澜不惊,上下天光,一碧万顷,沙鸥翔集,锦鳞游泳,岸芷汀兰,郁郁青青。
  </view>
  <template #footer>
    <wd-button size="small" plain>阅读全文</wd-button>
  </template>
</wd-card>

矩形卡片

设置 type="rectangle" 使用矩形卡片样式。

html
<wd-card title="生活记录" type="rectangle">
  <view class="list-group">
    <view class="list-item">
      <image src="https://wot-ui.cn/assets/panda.jpg" class="list-item__image" mode="aspectFill" />
      <view class="list-item__content">
        <view class="list-item__title">今天天气真好</view>
        <view class="list-item__desc">2026年2月11日 晴天 22℃</view>
      </view>
    </view>
  </view>
  <template #footer>
    <wd-button size="small" plain>点赞</wd-button>
  </template>
</wd-card>

组件样式

复杂卡片

结合图片、标签、属性区块可构建信息密度更高的卡片内容。

html
<wd-card title="宠物档案">
  <view class="info-card">...</view>
  <template #footer>
    <wd-button size="small" plain>点赞 (1.2w)</wd-button>
  </template>
</wd-card>

内容形态

自定义标题

使用 title 插槽自定义标题区域内容。

html
<wd-card type="rectangle">
  <template #title>
    <view class="custom-title">
      <view>兴趣爱好</view>
      <view class="custom-title__tip">
        <wd-icon name="heart" size="14px" custom-style="vertical-align: bottom; margin-right: 4px;" />
        快乐源泉
      </view>
    </view>
  </template>
  <view class="list-group">...</view>
</wd-card>

特殊样式

不传 footer 插槽时,底部区域不会渲染。

html
<wd-card title="精彩瞬间" type="rectangle">
  <view class="moment-card">...</view>
</wd-card>

Attributes

参数说明类型默认值
title卡片标题string-
type卡片类型,支持 rectanglestring-
custom-title-class标题区域自定义类名string''
custom-content-class内容区域自定义类名string''
custom-footer-class底部区域自定义类名string''
custom-class根节点自定义类名string''
custom-style根节点自定义样式string''

Slots

name说明
default卡片内容
title卡片标题
footer底部操作内容

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-card-bg$filled-oppo卡片背景色
--wot-card-border-color$border-light卡片边框颜色
--wot-card-radius$radius-large卡片圆角
--wot-card-shadow$n-0 $n-2 $n-8 $opac-2_04卡片阴影
--wot-card-shadow-hover$n-0 $n-4 $n-16 $opac-3_08卡片悬浮阴影
--wot-card-transitionbox-shadow 0.3s ease过渡动画
--wot-card-margin-bottom$spacing-extra-loose卡片底部间距
--wot-card-margin-horizontal$spacing-extra-loose卡片水平方向外边距
--wot-card-title-color$text-main标题颜色
--wot-card-title-font-size$typography-title-size-main标题字号
--wot-card-title-font-weight$font-weight-medium标题字重
--wot-card-title-line-height$typography-body-line--height-size-main标题行高
--wot-card-title-padding$padding-loose $padding-extra-loose标题内间距
--wot-card-content-color$text-secondary内容文字颜色
--wot-card-content-font-size$typography-body-size-main内容字号
--wot-card-content-line-height$typography-body-line--height-size-main内容行高
--wot-card-content-padding$padding-main $padding-loose内容内边距
--wot-card-content-border-color$border-main内容区域边框颜色
--wot-card-footer-padding$padding-tight $padding-loose底部内边距
--wot-card-footer-border-color$border-main底部分割线颜色

源代码

文档
组件

Released under the MIT License.

Released under the MIT License.