Skip to content

Card

Simple rectangular container.

When To Use

A card can be used to display content related to a single subject. The content can consist of multiple elements of varying types and sizes.

Examples

Basic card

vue
<template>
  <a-card title="Default size card" style="width: 300px">
    <template #extra><a href="#">More</a></template>
    <p>Card content</p>
    <p>Card content</p>
    <p>Card content</p>
  </a-card>
</template>

No border

vue
<template>
  <div style="background: #ececec; padding: 30px">
    <a-card title="Card title" :bordered="false" style="width: 300px">
      <p>Card content</p>
      <p>Card content</p>
      <p>Card content</p>
    </a-card>
  </div>
</template>

Simple card

vue
<template>
  <a-card style="width: 300px">
    <p>Card content</p>
    <p>Card content</p>
    <p>Card content</p>
  </a-card>
</template>

Customized content

vue
<template>
  <a-card hoverable style="width: 240px">
    <template #cover>
      <img
        alt="example"
        src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png"
      />
    </template>
    <template #actions>
      <setting-outlined key="setting" />
      <edit-outlined key="edit" />
      <ellipsis-outlined key="ellipsis" />
    </template>
    <a-card-meta
      title="Card title"
      description="This is the description"
    >
      <template #avatar>
        <a-avatar src="https://joeschmoe.io/api/v1/random" />
      </template>
    </a-card-meta>
  </a-card>
</template>

<script setup>
import { SettingOutlined, EditOutlined, EllipsisOutlined } from '@ant-design/icons-vue'
</script>

Card in column

vue
<template>
  <div style="background: #ececec; padding: 30px">
    <a-row :gutter="16">
      <a-col :span="8">
        <a-card title="Card title" :bordered="false">
          <p>Card content</p>
        </a-card>
      </a-col>
      <a-col :span="8">
        <a-card title="Card title" :bordered="false">
          <p>Card content</p>
        </a-card>
      </a-col>
      <a-col :span="8">
        <a-card title="Card title" :bordered="false">
          <p>Card content</p>
        </a-card>
      </a-col>
    </a-row>
  </div>
</template>

Loading card

vue
<template>
  <div>
    <a-card style="width: 300px; margin-top: 16px" :loading="loading">
      <template #actions>
        <setting-outlined key="setting" />
        <edit-outlined key="edit" />
        <ellipsis-outlined key="ellipsis" />
      </template>
      <a-card-meta
        title="Card title"
        description="This is the description"
      >
        <template #avatar>
          <a-avatar src="https://joeschmoe.io/api/v1/random" />
        </template>
      </a-card-meta>
    </a-card>
    <a-button style="margin-top: 16px" @click="loading = !loading">
      Toggle loading
    </a-button>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { SettingOutlined, EditOutlined, EllipsisOutlined } from '@ant-design/icons-vue'

const loading = ref(true)
</script>

Grid card

vue
<template>
  <a-card title="Card Title">
    <div class="card-container">
      <a-card-grid style="width:25%;textAlign:'center'">Content</a-card-grid>
      <a-card-grid hoverable style="width:25%;textAlign:'center'">Content</a-card-grid>
      <a-card-grid style="width:25%;textAlign:'center'">Content</a-card-grid>
      <a-card-grid style="width:25%;textAlign:'center'">Content</a-card-grid>
      <a-card-grid style="width:25%;textAlign:'center'">Content</a-card-grid>
      <a-card-grid style="width:25%;textAlign:'center'">Content</a-card-grid>
      <a-card-grid style="width:25%;textAlign:'center'">Content</a-card-grid>
    </div>
  </a-card>
</template>

<style scoped>
.card-container p {
  margin: 0;
}
</style>

Inner card

vue
<template>
  <a-card title="Card title">
    <p style="font-size: 14px; color: rgba(0, 0, 0, 0.85); margin-bottom: 16px; font-weight: 500">
      Group title
    </p>
    <a-card type="inner" title="Inner Card title" :extra="extra">
      Inner Card content
    </a-card>
    <a-card
      style="margin-top: 16px"
      type="inner"
      title="Inner Card title"
      :extra="extra"
    >
      Inner Card content
    </a-card>
  </a-card>
</template>

<script setup>
import { h } from 'vue'

const extra = h('a', { href: '#' }, 'More')
</script>

API

Card

PropertyDescriptionTypeDefaultVersion
actionsThe action list, shows at the bottom of the Cardslots-
activeTabKeyCurrent TabPane's keystring-
bodyStyleInline style to apply to the card contentobject-
borderedToggles rendering of the border around the cardbooleantrue
coverCard coverslot-
defaultActiveTabKeyInitial active TabPane's key, if activeTabKey is not setstring-
extraContent to render in the top-right corner of the cardstring | slot-
headStyleInline style to apply to the card headobject-
hoverableLift up when hovering cardbooleanfalse
loadingShows a loading indicator while the contents of the card are being fetchedbooleanfalse
sizeSize of carddefault | smalldefault
tabBarExtraContentExtra content in tab barslot-
tabListList of TabPane's headArray<{key: string, tab: any}>-
tabPropsTabs--
titleCard titlestring | slot-
typeCard type, can be set to inner or not setstring-

Card Events

Events NameDescriptionArgumentsVersion
tabChangeCallback when tab is switched(key) => void

Card.Grid

PropertyDescriptionTypeDefaultVersion
classThe className of containerstring-
hoverableLift up when hovering card gridbooleantrue
styleThe style object of containerobject-

Card.Meta

PropertyDescriptionTypeDefaultVersion
avatarAvatar or iconslot-
descriptionDescription contentstring | slot-
titleTitle contentstring | slot-

Released under the MIT License.