自定义内容
content 插槽用于替换徽标的内容,例如放入一个图标。
徽标是否渲染仍然由 content 属性决定,因此使用插槽时 content 也要设置为非空值。此时应当通过 label 提供无障碍名称。
<script setup lang="ts">
import { Bookmark, Check } from '@lucide/vue'
import { Badge, IconButton } from '@hina-ui/vue'
</script>
<template>
<Badge content="已完成" tone="success" size="md" label="已完成">
<template #content>
<Check class="size-3" />
</template>
<IconButton label="收藏" variant="soft">
<Bookmark />
</IconButton>
</Badge>
</template>
vue
设置 bare 后徽标不绘制底色,也没有内边距,只负责定位与描边,尺寸由插槽内容决定。把 Indicator 放入插槽即可在头像角上显示状态点。
<script setup lang="ts">
import { Avatar, Badge, Indicator, Inline } from '@hina-ui/vue'
</script>
<template>
<Inline gap="lg">
<Badge content="online" bare label="在线" placement="bottom-end" shape="circle">
<template #content>
<Indicator tone="success" size="lg" />
</template>
<Avatar src="/avatars/paper.webp" alt="星见书音" />
</Badge>
<Badge content="away" bare label="离开" placement="bottom-end" shape="circle">
<template #content>
<Indicator tone="warning" size="lg" />
</template>
<Avatar name="星见书音" />
</Badge>
</Inline>
</template>
vue