Files
heroui-vue/apps/docs/demos/error-message-custom-styles.vue
maoyingjie af6bfda3ee feat: migrate Tag, TagGroup and ErrorMessage with collection and focus contracts
Port the fixed HeroUI baseline tag/tag-group/error-message components onto the
existing collection selection/registry protocols instead of a second state model.

- TagGroup owns selection, disabled scope, removal requests and name/description
  wiring; TagGroupList renders the role=grid node and Tag renders role=row.
- Removal has one path: a press inside the remove subtree is a removal request,
  so custom remove buttons work without a second event source; focus follows the
  next neighbour only after the item is actually gone.
- ErrorMessage keeps the baseline slot marker and reuses the field part ids
  without gaining validation or aria-invalid semantics.
- Ship the 12 tag-group and 2 error-message previews, both doc pages, navigation,
  a 35-case behavioural suite and independent tarball consumption checks.
2026-10-25 10:45:43 +08:00

35 lines
801 B
Vue

<script setup lang="ts">
import { computed, ref } from "vue";
import {
Description,
ErrorMessage,
Label,
Tag,
TagGroup,
TagGroupList,
type TagKey,
} from "@heroui-vue/components";
const selected = ref<TagKey[]>([]);
const isInvalid = computed(() => selected.value.length === 0);
</script>
<template>
<TagGroup
v-model="selected"
class="w-full max-w-xs gap-1.5"
selection-mode="multiple"
>
<Label>主题</Label>
<TagGroupList>
<Tag id="api">API</Tag>
<Tag id="design">设计</Tag>
<Tag id="docs">文档</Tag>
</TagGroupList>
<Description>请至少选择一个主题</Description>
<ErrorMessage class="font-medium text-danger">
{{ isInvalid ? "请至少选择一个主题" : "" }}
</ErrorMessage>
</TagGroup>
</template>