Skip to content

PubAvatar

This is an avatar component that can be used to display a user's profile picture. It provides various options for customizing the avatar, such as adding a border, shadow, and rounded corners.

Default avatar

My Avatar
My Avatar
vue
<template>
  <div class="flex justify-center space-x-4">
    <pub-avatar src="/images/avatar001.jpeg" />
    <pub-avatar
      src="/images/avatar001.jpeg"
      rounded
    />
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar } from 'vuelicity'
</script>

Bordered avatar

Prop - bordered Usage

The bordered prop can be used to add a border to the avatar.

My Avatar
My Avatar
vue
<template>
  <div class="flex justify-center space-x-4">
    <pub-avatar
      src="/images/avatar001.jpeg"
      bordered
    />
    <pub-avatar
      src="/images/avatar001.jpeg"
      bordered
      rounded
    />
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar } from 'vuelicity'
</script>

Placeholder icon

vue
<template>
  <div class="flex justify-center space-x-4">
    <pub-avatar />
    <pub-avatar rounded />
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar } from 'vuelicity'
</script>

Placeholder initials

Prop - initials Usage

The initials prop can be used to display the initials of the user.

PC
PC
vue
<template>
  <div class="flex justify-center space-x-4">
    <pub-avatar initials="PC" />
    <pub-avatar
      initials="PC"
      rounded
    />
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar } from 'vuelicity'
</script>

Alternate placeholder icon

Slot - placeholder Usage

The placeholder slot can be used to display a custom placeholder icon.

vue
<template>
  <div class="flex justify-center space-x-4">
    <pub-avatar>
      <template #placeholder>
        <pub-icon
          name="user-circle"
          aschild
        />
      </template>
    </pub-avatar>
    <pub-avatar rounded>
      <template #placeholder>
        <pub-icon
          name="user-circle"
          aschild
        />
      </template>
    </pub-avatar>
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar, PubIcon } from 'vuelicity'
</script>

Dot indicator

Prop - status Usage

My Avatar
My Avatar
My Avatar
My Avatar
vue
<template>
  <div class="flex justify-center space-x-4">
    <pub-avatar
      src="/images/avatar003.jpeg"
      status="online"
    />
    <pub-avatar
      src="/images/avatar003.jpeg"
      status="busy"
    />
    <pub-avatar
      src="/images/avatar003.jpeg"
      status="offline"
    />
    <pub-avatar
      src="/images/avatar003.jpeg"
      status="away"
    />
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar } from 'vuelicity'
</script>

Dot indicator position

Prop - statusPosition Usage

The statusPosition prop can be used to adjust the position of the dot indicator.

My Avatar
My Avatar
My Avatar
My Avatar
vue
<template>
  <div class="flex justify-center space-x-4">
    <pub-avatar
      src="/images/avatar003.jpeg"
      status="online"
      status-position="top-left"
    />
    <pub-avatar
      src="/images/avatar003.jpeg"
      status="online"
      status-position="top-right"
    />
    <pub-avatar
      src="/images/avatar003.jpeg"
      status="online"
      status-position="bottom-left"
    />
    <pub-avatar
      src="/images/avatar003.jpeg"
      status="online"
      status-position="bottom-right"
    />
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar } from 'vuelicity'
</script>

Sizes

Prop - size Usage

The size prop can be used to adjust the size of the avatar.

My Avatar
My Avatar
My Avatar
My Avatar
My Avatar
vue
<template>
  <div class="flex justify-center items-center space-x-4">
    <pub-avatar
      src="/images/avatar002.jpeg"
      size="xs"
    />
    <pub-avatar
      src="/images/avatar002.jpeg"
      size="sm"
    />
    <pub-avatar
      src="/images/avatar002.jpeg"
      size="md"
    />
    <pub-avatar
      src="/images/avatar002.jpeg"
      size="lg"
    />
    <pub-avatar
      src="/images/avatar002.jpeg"
      size="xl"
    />
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar } from 'vuelicity'
</script>

Stacked avatars

Prop - stacked Usage

The stacked prop can be used to stack multiple avatars together.

vue
<template>
  <div class="grid gap-2">
    <pub-avatar-stack>
      <pub-avatar
        src="/images/avatar001.jpeg"
        rounded
        stacked
      />
      <pub-avatar
        src="/images/avatar002.jpeg"
        rounded
        stacked
      />
      <pub-avatar
        src="/images/avatar003.jpeg"
        rounded
        stacked
      />
      <pub-avatar
        src="/images/avatar004.jpeg"
        rounded
        stacked
      />
      <pub-avatar
        src="/images/avatar005.jpeg"
        rounded
        stacked
      />
    </pub-avatar-stack>
    <pub-avatar-stack>
      <pub-avatar
        src="/images/avatar001.jpeg"
        rounded
        stacked
      />
      <pub-avatar
        src="/images/avatar002.jpeg"
        rounded
        stacked
      />
      <pub-avatar
        src="/images/avatar003.jpeg"
        rounded
        stacked
      />
      <pub-avatar
        src="/images/avatar004.jpeg"
        rounded
        stacked
      />
      <pub-avatar-stack-counter
        href="#"
        total="99"
      />
    </pub-avatar-stack>
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar, PubAvatarStack, PubAvatarStackCounter } from 'vuelicity'
</script>

Alternative text

Prop - alt Usage

The alt prop can be used to provide alternative text for the avatar.

Carolina Avatar
vue
<template>
  <div class="flex justify-center space-x-4">
    <pub-avatar
      src="/images/avatar001.jpeg"
      alt="Carolina Avatar"
    />
  </div>
</template>

<script lang="ts" setup>
import { PubAvatar } from 'vuelicity'
</script>

Reference

PubAvatar

Properties

NameTypeDefaultDescriptionOptions
srcString''The source URL for the avatar image.
altString''Alternative text for the avatar image.
sizeString'md'The size of the avatar.'xs', 'sm', 'md', 'lg', 'xl'
borderedBooleanfalseWhether to add a border to the avatar.
roundedBooleanfalseWhether to add rounded corners to the avatar.
initialsString''Initials to display as a placeholder.
statusString''The status indicator theme or state.'online', 'offline', 'busy', 'away'
statusPositionString'bottom-right'The position of the status indicator.'top-right', 'top-left', 'bottom-right', 'bottom-left'
stackedBooleanfalseWhether the avatar is part of a stacked group.
classString''Additional CSS classes to apply.

Slots

NameDescription
placeholderCustom content to display as a placeholder icon.

PubAvatarStack

Slots

NameDescription
defaultSlot for PubAvatar components.

PubAvatarStackCounter

Properties

NameTypeDefaultDescriptionOptions
totalNumber0The total number of items.
hrefString''The href attribute for the counter link.

Released under the MIT License.