Files
heroui-vue/apps/docs/demos/badge-placements.vue
T
2026-10-21 21:32:40 +08:00

46 lines
1.0 KiB
Vue

<script setup lang="ts">
import {
Avatar,
AvatarImage,
AvatarFallback,
Badge,
BadgeAnchor,
} from "@heroui-vue/components";
const AVATAR_URL =
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg";
const placements = [
"top-right",
"top-left",
"bottom-right",
"bottom-left",
] as const;
const PLACEMENT_LABELS: Record<(typeof placements)[number], string> = {
"bottom-left": "左下",
"bottom-right": "右下",
"top-left": "左上",
"top-right": "右上",
};
</script>
<template>
<div class="flex items-center gap-8">
<div
v-for="placement in placements"
:key="placement"
class="flex flex-col items-center gap-2"
>
<BadgeAnchor>
<Avatar>
<AvatarImage alt="头像" :src="AVATAR_URL" />
<AvatarFallback>JD</AvatarFallback>
</Avatar>
<Badge color="accent" :placement="placement" size="sm" />
</BadgeAnchor>
<span class="text-xs text-muted">{{ PLACEMENT_LABELS[placement] }}</span>
</div>
</div>
</template>