๐ข Avatar Group
Basic
NAvatarGroup - used to display a group of NAvatar components.
| Prop | Default | Description |
|---|---|---|
| max | 3 | The maximum number of avatars to display before the rest are hidden. |
Size
| Prop | Default | Description |
|---|---|---|
| size | md | The size of the avatars in the group. |
๐ You can freely adjust the size of the avatars in the group using any size imaginable. No limits exist, and you can use
breakpointssuch assm:sm, xs:lgto change size based on screen size orstatessuch ashover:lg, focus:3xlto change size based on input state and more.
size prop to set the size of the entire NAvatar or you can set the size of individual avatars using the size prop on the NAvatar component.Customization
Similar to the size prop, any available props of the NAvatar component can be directly passed to the NAvatarGroup component. These props will then be automatically forwarded to the individual NAvatar components within the group.
You can also individually customize each NAvatar, refer to the NAvatar component for more information.
You can also use the una prop to add utility classes, refer to the Props and Presets sections for more information.
Props
import type { NAvatarProps } from './avatar'
/**
* This extends the `NAvatarProps` interface.
*
* @see https://github.com/una-ui/una-ui/blob/main/packages/nuxt/src/runtime/types/avatar.ts
*/
export interface NAvatarGroupProps extends Omit<NAvatarProps, 'una'> {
/**
* Set the maximum number of avatars to show.
*
* @default 3
*/
max: number
/**
* `Una
*
* @see https://github.com/una-ui/una-ui/blob/main/packages/preset/src/_shortcuts/avatar-group.ts
* @see https://github.com/una-ui/una-ui/blob/main/packages/preset/src/_shortcuts/avatar.ts
*/
una?: {
avatarGroup?: string
avatarGroupChild?: string
avatarGroupMargin?: string
avatarGroupLabel?: string
} & NAvatarProps['una']
}
Presets
type AvatarGroupPrefix = 'avatar-group'
export const staticAvatarGroup: Record<`${AvatarGroupPrefix}-${string}` | AvatarGroupPrefix, string> = {
'avatar-group': 'flex flex-row-reverse justify-end',
'avatar-group-child': 'ring-2 ring-$c-background',
'avatar-group-margin': '-me-1.5 first:me-0',
'avatar-group-label': 'text-.9em',
}
export const dynamicAvatarGroup: [RegExp, (params: RegExpExecArray) => string][] = [
]
export const avatarGroup = [
...dynamicAvatarGroup,
staticAvatarGroup,
]
Component
<script setup lang="ts">
import type { NAvatarGroupProps } from '../../types'
import NAvatarGroupDefaultSlot from '../slots/AvatarGroupDefault'
defineOptions({
inheritAttrs: false,
})
const props = withDefaults(defineProps<NAvatarGroupProps>(), {
max: 3,
})
</script>
<template>
<div
avatar-group
v-bind="$attrs"
:class="una?.avatarGroup"
>
<NAvatarGroupDefaultSlot
:max="max"
:avatar="props"
>
<slot />
</NAvatarGroupDefaultSlot>
</div>
</template>