Skip to content

Card ​

An information aggregation container that supports a cover, header, body, footer, and a loading placeholder.

Basic usage ​

vue
<template>
  <lh-card title="水墨">
    <view>Card content</view>
  </lh-card>
</template>
vue
<template>
  <lh-card title="Landscape album">
    <template #cover>
      <image class="cover" src="https://placeholder.invalid/cover.png" mode="aspectFill" />
    </template>
    <view>Card content</view>
    <template #footer>
      <view>Footer actions</view>
    </template>
  </lh-card>
</template>

Children inside the cover need an explicit width

The "cover children fill the width" rule from share (.lh-card__cover > *) relies on a wildcard selector that WXSS does not support, and the sanitization pipeline drops it. On the Mini Program, give children inside the cover such as <image> an explicit width (for example width: 100%).

Header right action area ​

The extra slot is rendered to the right of the title and appears only when a title or a header slot exists.

vue
<template>
  <lh-card title="Order">
    <template #extra>
      <lh-button size="small" text>View more</lh-button>
    </template>
    <view>Card content</view>
  </lh-card>
</template>

Shadow and clickable ​

vue
<template>
  <lh-card shadow="hover" clickable @click="onClick">
    <view>Raises on hover, emits an event on click</view>
  </lh-card>
</template>

<script setup lang="ts">
const onClick = () => console.log('Card clicked')
</script>

Loading placeholder ​

vue
<template>
  <lh-card title="水墨" loading>
    <view>Not rendered while the content is loading</view>
  </lh-card>
</template>

Props ​

PropDescriptionTypeDefault
titleCard title (the header slot can also be used)string—
shadowWhen the shadow is shown'always' | 'hover' | 'never''always'
clickableThe whole card is clickable (carries the button keyboard semantics)booleanfalse
loadingLoading state: the content area is replaced by a skeleton placeholderbooleanfalse
themeVarsComponent-level theme variables (the keys get the --lh- prefix automatically)Record<string, string>—
bgPatternPattern background URL (such as var(--lh-pattern-willow)), not restricted by the global allowliststring—
customClassCustom class namestring—
sxQuick layout propsLhSxProps—

Events ​

EventDescriptionCallback parameters
clickClick on the whole card (emitted only when clickable)(e: Event)

Slots ​

SlotDescription
coverCover
headerHeader (takes precedence over title)
extraHeader right action area (requires the header to exist)
defaultBody content
footerFooter

Keyboard activation is H5-only

A clickable card supports Enter / Space keyboard activation on H5 (aligned with the APG button pattern); the Mini Program has no keyboard events, so this handling is removed from the MP target by conditional compilation.