Skip to content

TagGroup 标签组

MoTagGroup 用于标签筛选、状态切换和多选条件组合。支持单选、多选、禁用、尺寸、间距和自定义颜色。

单选

Light

当前值:all

Dark

当前值:all

vue
<script setup lang="ts">
import { ref } from "vue";

const active = ref("all");
const options = [
  { label: "全部", value: "all" },
  { label: "运行中", value: "running" },
  { label: "已停止", value: "stopped" }
];
</script>

<template>
  <MoTagGroup v-model="active" :options="options" />
</template>

多选

Light

当前值:image

Dark

当前值:image

vue
<MoTagGroup v-model="values" multiple :options="options" />

尺寸

Light
Dark
vue
<MoTagGroup v-model="active" size="small" :options="options" />
<MoTagGroup v-model="active" :options="options" />
<MoTagGroup v-model="active" size="large" :options="options" />

自定义颜色

Light
Dark
vue
<MoTagGroup
  v-model="active"
  :options="options"
  active-background-color="#7c3aed"
  active-text-color="#ffffff"
/>

自定义内容

Light
Dark
vue
<MoTagGroup v-model="active" :options="options">
  <template #item="{ option, selected }">
    <span>{{ option.label }} - {{ selected ? "已选" : "可选" }}</span>
  </template>
</MoTagGroup>

API

属性说明类型默认值
v-model当前选中值TagGroupValue | TagGroupValue[]undefined
options标签项TagGroupOption[][]
theme主题light | darkdark
size尺寸small | default | largedefault
multiple是否多选booleanfalse
gap标签间距string | number8
backgroundColor默认背景色string-
activeBackgroundColor选中背景色string-
textColor默认文字色string-
activeTextColor选中文字色string-
disabled是否整体禁用booleanfalse

TagGroupOption

字段说明类型
label标签文本string
value标签值string | number
disabled是否禁用boolean
backgroundColor当前项默认背景色string
activeBackgroundColor当前项选中背景色string
textColor当前项默认文字色string
activeTextColor当前项选中文字色string

Events

事件说明回调参数
change选中值变化时触发value, option
update:modelValue选中值变化时触发value

Slots

插槽说明
item自定义标签项,参数 { option, index, selected }