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/tag.md.

VTag 标签

VTag 用于展示分类、状态或属性标记。

引入

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

示例

不同主题

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

<template>
  <VSpace>
    <VTag>默认</VTag>
    <VTag theme="primary">主要</VTag>
    <VTag theme="secondary">次要</VTag>
    <VTag theme="danger">危险</VTag>
  </VSpace>
</template>

圆角标签

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

<template>
  <VSpace>
    <VTag rounded>已发布</VTag>
    <VTag rounded theme="primary">草稿</VTag>
  </VSpace>
</template>

带图标

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

<template>
  <VSpace>
    <VTag theme="primary">
      <template #leftIcon>
        <IconCheckboxCircle />
      </template>
      已发布
    </VTag>
    <VTag theme="secondary">
      <template #leftIcon>
        <IconTimerLine />
      </template>
      定时发布
    </VTag>
  </VSpace>
</template>

自定义样式

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

<template>
  <VTag :styles="{ backgroundColor: '#e0f2fe', color: '#0369a1' }">
    自定义颜色
  </VTag>
</template>

Props

属性类型默认值说明
theme"default" | "primary" | "secondary" | "danger""default"标签主题
roundedbooleanfalse是否显示为圆角标签
stylesCSSProperties{}自定义样式

Slots

插槽说明
default标签内容
leftIcon左侧图标
rightIcon右侧图标