PXD

Avatar

Avatars represent a user or a team

Default

<template>
  <PStack>
    <PAvatar src="https://avatars.githubusercontent.com/u/6880091?v=4" />
    <PAvatar src="https://avatars.githubusercontent.com/u/9113740?v=4" />
    <PAvatar src="https://avatars.githubusercontent.com/u/13041?v=4" />
  </PStack>
</template>

Group

+2
<script setup>
const options = [
  { src: 'https://avatars.githubusercontent.com/u/6880091?v=4' },
  { src: 'https://avatars.githubusercontent.com/u/9113740?v=4' },
  { src: 'https://avatars.githubusercontent.com/u/13041?v=4' },
  { src: 'https://avatars.githubusercontent.com/u/169298?v=4' },
  { src: 'https://avatars.githubusercontent.com/u/3676859?v=4' },
]
</script>

<template>
  <PAvatarGroup :options="options" :max="3" size="28" />
</template>

Badge

<script setup>
import LogoGithubIcon from '@gdsicon/vue/logo-github'
</script>

<template>
  <PAvatar src="https://avatars.githubusercontent.com/u/6880091?v=4">
    <template #icon>
      <LogoGithubIcon />
    </template>
  </PAvatar>
</template>

With custom icon

<script setup>
import ArrowCircleDownIcon from '@gdsicon/vue/arrow-circle-down'
import CheckCircleFillIcon from '@gdsicon/vue/check-circle-fill'
import ClockDashedIcon from '@gdsicon/vue/clock-dashed'
</script>

<template>
  <PStack direction="vertical">
    <PAvatar placeholder>
      <template #icon>
        <ArrowCircleDownIcon class="text-gray-900" />
      </template>
    </PAvatar>
    <PAvatar placeholder>
      <template #icon>
        <CheckCircleFillIcon class="text-gray-900" />
      </template>
    </PAvatar>
    <PAvatar placeholder>
      <template #icon>
        <ClockDashedIcon class="text-gray-900" />
      </template>
    </PAvatar>
  </PStack>
</template>

Text Avatar

LT
<template>
  <PAvatar alt="LT" />
</template>

Loading

<template>
  <PAvatar src="https://avatars.githubusercontent.com/u/3676859?v=4" loading />
</template>

Placeholder

<template>
  <PAvatar placeholder />
</template>

Props

NameTypeDefaultDescription
srcstring-URL of the image to display
altstring-Image alt text, also used as the initials fallback
sizenumber | string-Diameter in px, inherits the group size when nested
loadingboolean-Show a spinning ring over the avatar
placeholderboolean-Render the shimmering placeholder instead of the image

Events

NameTypeDescription
load(event: Event) => voidEmitted when the avatar image has finished loading.
error(event: Event) => voidEmitted when the avatar image fails to load or its request is aborted.
loadstart(event: Event) => voidEmitted when the avatar image starts loading.

AvatarGroup Props

NameTypeDefaultDescription
maxnumber5Avatars shown before the +N counter appears
sizenumber | string-Diameter in px applied to every avatar in the group
optionsAvatarOptions[]() => []Avatars to render, each with src, alt and loading

Slots

NameDescription
defaultDefault slot

Methods

NameTypeDescription
getLoadingStatus() => AvatarStatusReturn the current image loading status.

Source

Source