Skip to content

Card

A versatile card container for text, lists, images, paragraphs, and other content.

Basic Usage

Set the card title with the header prop.

Card Title

Card content. This is some descriptive text.

Cards can contain text, lists, images, paragraphs, etc.

Basic Usage

Simple Card

The title can be omitted, keeping only the content area.

A simple card without a title.

Simple Card

Extra Actions

Use the #extra slot to add action buttons on the right side of the header.

Card Title

Card with extra actions.

Extra Actions

Shadow

Control when the card shadow appears with the shadow prop.

Always Shadow

This card always shows shadow.

Hover Shadow

This card only shows shadow on hover.

Never Shadow

This card never shows shadow.

Shadow

Hover Effect

Set the hoverable prop to create a lift effect on hover.

Hoverable Card

Has a lift effect on hover.

Hover Effect

Loading State

Set the loading prop to show a skeleton loading state.

Loading

Use the #footer slot to add footer content.

Card with Footer

Card content area.

Footer

Sizes

Set the card size with the size prop.

Small Card

A small-sized card.

Default Card

A default-sized card.

Large Card

A large-sized card.

Sizes

Borderless

Set bordered to false to remove the border.

Borderless Card

A card without borders.

Borderless

Use in Nuxt

The Card component fully supports Nuxt 3/4 environments. Since it is primarily used for structured layouts, server-side rendering (SSR) can pre-generate the complete DOM structure, benefiting SEO optimization and first-screen rendering performance.

Nuxt in Practice

In Nuxt, the Card component and all its child components (such as Button, Tag) have built-in auto-import support.

SSR ReadyAuto Import
Use in Nuxt

SSR Notes:

  • ✅ Header, footer, and content areas fully rendered on the server
  • ✅ Shadow effects (always/hover/never) support SSR
  • ✅ Skeleton loading state (loading) displays on first screen during SSR, avoiding blank screens
  • ✅ Size and bordered configurations take effect via CSS class names on the server
  • 💡 Interactive logic and dynamic loading state toggling recover reactivity after client-side activation (Hydration)

SEO Optimization

The HTML generated by the Card component is semantically clear. It is recommended to use appropriate heading tags (such as h3) in the header slot to further improve search engine understanding of page content.

API

Props

PropDescriptionTypeDefault
headerCard titlestring
body-styleStyle for the card content areaobject
header-styleStyle for the card headerobject
shadowWhen to show card shadow'always' | 'hover' | 'never''always'
borderedWhether to show borderbooleantrue
hoverableWhether hoverable (lift effect on hover)booleanfalse
sizeCard size'small' | 'default' | 'large''default'
loadingWhether loading (shows skeleton)booleanfalse
body-paddingWhether to have paddingbooleantrue

Slots

Slot NameDescription
defaultCard content
headerCard title
extraCard extra action area
footerCard footer content

Theme Variables

VariableDescriptionDefault
--yh-card-bg-colorBackground colorvar(--yh-bg-color-overlay)
--yh-card-border-colorBorder colorvar(--yh-border-color-light)
--yh-card-border-radiusBorder radiusvar(--yh-border-radius-base)
--yh-card-header-paddingHeader padding18px 20px
--yh-card-body-paddingBody padding20px
--yh-card-footer-paddingFooter padding18px 20px
--yh-card-shadowCard shadowvar(--yh-box-shadow-light)

Released under the MIT License.