Avatar Group
把头像叠成一排。max 限制个数,多出来的显示成 +N。
Installation
pnpm dlx @weme-ui/weme-ui add avatar-groupUsage
+1ABC
Vueexamples/usage.vueExpand codeHide code
<script lang="ts" setup>
import AvatarGroup from '../avatar-group.vue'
const items = [{ fallback: 'A' }, { fallback: 'B' }, { fallback: 'C' }, { fallback: 'D' }]
</script>
<template>
<div class="flex gap-3 items-center">
<AvatarGroup :items="items" :max="3" />
</div>
</template>Examples
Colors
ABC
ABC
ABC
ABC
ABC
ABC
ABC
ABC
Vueexamples/colors.vueExpand codeHide code
<script lang="ts" setup>
import AvatarGroup from '../avatar-group.vue'
const colors = [
'default',
'accent',
'neutral',
'info',
'success',
'warning',
'error',
'inverse',
] as const
const items = [{ fallback: 'A' }, { fallback: 'B' }, { fallback: 'C' }]
</script>
<template>
<div class="flex flex-col gap-3 items-start">
<AvatarGroup v-for="color in colors" :key="color" :items="items" :color="color" />
</div>
</template>Sizes
ABC
ABC
ABC
ABC
ABC
ABC
ABC
ABC
Vueexamples/sizes.vueExpand codeHide code
<script lang="ts" setup>
import AvatarGroup from '../avatar-group.vue'
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'] as const
const items = [{ fallback: 'A' }, { fallback: 'B' }, { fallback: 'C' }]
</script>
<template>
<div class="flex flex-col gap-3 items-start">
<AvatarGroup v-for="size in sizes" :key="size" :items="items" :size="size" />
</div>
</template>Props
PropTypeDefault
asAsTag | Component'div'
根节点渲染为的元素或组件(Reka UI
Primitive)AsTag | Component'div'
color'default' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'inverse'-
下发给子 Avatar 和
+N 的颜色。单项自己的 color 优先'default' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error' | 'inverse'-
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl''md'
下发给子 Avatar 和
+N 的尺寸。单项自己的 size 优先'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl''md'
itemsAvatarGroupItem[]-
头像列表。单项是去掉
crossOrigin、referrerPolicy、delayMs 之后的 Avatar propsAvatarGroupItem[]-
maxnumber-
只取前几项。行是反过来排的,第一项靠右,
+N 在最右number-crossOrigin'' | 'anonymous' | 'use-credentials'-
声明在 props 上。当前模板没有传给子 Avatar
'' | 'anonymous' | 'use-credentials'-
referrerPolicy'' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'-
声明在 props 上。当前模板没有传给子 Avatar
'' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'-
delayMsnumber-
声明在 props 上。当前模板没有传给子 Avatar
number-classany-
根节点额外 class
any-uiPartial<AvatarGroupStyleSlots>-
覆盖 slots 样式(
root / item)Partial<AvatarGroupStyleSlots>-
Slots
SlotDescription
default自定义整组内容。传入后不再根据 items 和 max 渲染子 Avatar
自定义整组内容。传入后不再根据
items 和 max 渲染子 AvatarFiles
src/components/avatar-group/avatar-group.vuesrc/components/avatar-group/avatar-group.props.tssrc/components/avatar-group/avatar-group.style.ts