For AI agents: the complete documentation index is available at https://docs.halo.run/llms.txt, the full documentation bundle is available at https://docs.halo.run/llms-full.txt, and this page is available as Markdown at https://docs.halo.run/developer-guide/plugin/api-reference/ui/base-components/card.md.

VCard 卡片

VCard 是一个带边框和阴影的内容容器,用来把相关的内容和操作组织在一起。

引入

import { VCard } from "@halo-dev/components";

示例

基础用法

<script lang="ts" setup>
import { VCard } from "@halo-dev/components";
</script>

<template>
  <VCard title="关于 Halo">
    Halo 是一个强大易用的开源建站工具,拥有丰富的可扩展性。
  </VCard>
</template>

带头部操作

<script lang="ts" setup>
import { VButton, VCard } from "@halo-dev/components";
</script>

<template>
  <VCard title="文章">
    <template #actions>
      <VButton size="sm" type="primary">新建文章</VButton>
    </template>
    这里展示文章列表。
  </VCard>
</template>

带页脚

<script lang="ts" setup>
import { VButton, VCard, VSpace } from "@halo-dev/components";
</script>

<template>
  <VCard title="站点信息">
    <p class="text-sm text-gray-600">修改站点名称和描述。</p>
    <template #footer>
      <VSpace>
        <VButton size="sm" type="primary">保存</VButton>
        <VButton size="sm">取消</VButton>
      </VSpace>
    </template>
  </VCard>
</template>

自定义头部

<script lang="ts" setup>
import { VCard, VTag } from "@halo-dev/components";
</script>

<template>
  <VCard>
    <template #header>
      <div class="flex w-full items-center justify-between px-4 py-3">
        <span class="text-base font-bold">插件设置</span>
        <VTag theme="primary">已启用</VTag>
      </div>
    </template>
    插件设置内容。
  </VCard>
</template>

Props

属性类型默认值说明
titlestringundefined卡片标题
bodyClassstring[]undefined应用到卡片主体区域的 class 列表

Slots

插槽说明
default卡片主体内容
header自定义整个头部区域,会覆盖 title 和 actions
actions头部右侧的操作区域
footer卡片底部区域,存在时才显示