Avatar
Avatars are used to represent a user or a system entity. They can be used to represent a person, a group of people, or an object.
import { VAvatar, VIcon } from '@vonage/vivid-api-vue';<script setup lang="ts">import { VAvatar, VIcon } from '@vonage/vivid-api-vue';</script>
<template> <VAvatar> <template #icon><VIcon name="user-line" label="User's avatar" /></template> </VAvatar></template>import { registerAvatar } from '@vonage/vivid-api';registerAvatar('your-prefix');<script type="module"> import { registerAvatar } from '@vonage/vivid-api'; registerAvatar('your-prefix');</script>
<your-prefix-avatar> <vwc-icon slot="icon" name="user-line" label="User's avatar"></vwc-icon></your-prefix-avatar>Use the icon slot to add an icon to the avatar.
To maintain accessibility, always provide a label property for the slotted icon — read more in the Icon component guidelines.
<script setup lang="ts">import { VAvatar, VIcon } from '@vonage/vivid-api-vue';</script>
<template> <VAvatar> <template #icon><VIcon name="assign-user-solid" label="Verified user's avatar" /></template> </VAvatar></template><vwc-avatar> <vwc-icon slot="icon" name="assign-user-solid" label="Verified User's avatar"></vwc-icon></vwc-avatar>Use the graphic slot to set any graphic media (e.g. image or SVG) as the avatar content.
<script setup lang="ts">import { VAvatar } from '@vonage/vivid-api-vue';</script>
<template> <div class="container"> <VAvatar shape="pill" connotation="cta"> <img slot="graphic" src="https://images.pexels.com/photos/762080/pexels-photo-762080.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" alt="woman" /> </VAvatar>
<VAvatar shape="pill" connotation="cta"> <svg slot="graphic" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 349.66 349.66" fill="none"> <path d="M258.65 229.64h-151.92c-16.65 0-35.17-13.51-41.34-30.16L1.99 30.16C-4.19 13.51 4.3 0 20.96 0h151.91c16.65 0 35.17 13.51 41.34 30.16l63.38 169.32c6.18 16.65-2.31 30.16-18.97 30.16z" fill="url(#grad)" /> <defs> <linearGradient id="grad" x1="0" y1="0" x2="349.66" y2="349.66" gradientUnits="userSpaceOnUse"> <stop stop-color="#A662FF" /> <stop offset="1" stop-color="#57EDFD" /> </linearGradient> </defs> </svg> </VAvatar> </div>
</template>
<style scoped>.container { display: inline-flex; gap: 4px;}</style><div class="container"> <vwc-avatar shape="pill" connotation="cta"> <img slot="graphic" src="https://images.pexels.com/photos/762080/pexels-photo-762080.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" alt="woman" /> </vwc-avatar>
<vwc-avatar shape="pill" connotation="cta"> <svg slot="graphic" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 349.66 349.66" fill="none"> <path d="M258.65 229.64h-151.92c-16.65 0-35.17-13.51-41.34-30.16L1.99 30.16C-4.19 13.51 4.3 0 20.96 0h151.91c16.65 0 35.17 13.51 41.34 30.16l63.38 169.32c6.18 16.65-2.31 30.16-18.97 30.16z" fill="url(#grad)" /> <defs> <linearGradient id="grad" x1="0" y1="0" x2="349.66" y2="349.66" gradientUnits="userSpaceOnUse"> <stop stop-color="#A662FF" /> <stop offset="1" stop-color="#57EDFD" /> </linearGradient> </defs> </svg> </vwc-avatar></div>
<style> .container { display: inline-flex; gap: 4px; }</style>| Property | Type | Default | Description |
|---|---|---|---|
| appearance | 'filled' | 'outlined' | 'duotone' | 'subtle' | Sets the element's appearance | |
| clickable | boolean | Indicates whether avatar should be a clickable <button> element. | |
| connotation | 'accent' | 'cta' | Sets the element's connotation | |
| download | string | Prompts the user to save the linked URL. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| href | string | The URL the hyperlink references. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| hreflang | string | Hints at the language of the referenced resource. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| initials | string | Sets the initials on the Avatar | |
| ping | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| referrerpolicy | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| rel | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| shape | 'rounded' | 'pill' | Sets the element's shape | |
| size | 'condensed' | 'normal' | 'expanded' | Sets the element's size | |
| target | '_self' | '_blank' | '_parent' | '_top' | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| type | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. |
| Property | Type | Default | Description |
|---|---|---|---|
| appearance | 'filled' | 'outlined' | 'duotone' | 'subtle' | Sets the element's appearance | |
| clickable | boolean | Indicates whether avatar should be a clickable <button> element. | |
| connotation | 'accent' | 'cta' | Sets the element's connotation | |
| download | string | Prompts the user to save the linked URL. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| href | string | The URL the hyperlink references. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| hreflang | string | Hints at the language of the referenced resource. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| initials | string | Sets the initials on the Avatar | |
| ping | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| referrerpolicy | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| rel | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| shape | 'rounded' | 'pill' | Sets the element's shape | |
| size | 'condensed' | 'normal' | 'expanded' | Sets the element's size | |
| target | '_self' | '_blank' | '_parent' | '_top' | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. | |
| type | string | See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a | <a> element for more information. |
| Name | Description |
|---|---|
| graphic | Assign nodes to the graphic slot to set a graphic media of any kind (e.g. image, illustration etc). |
| icon | The preferred way to add an icon to the component. |
| Name | Description |
|---|---|
| graphic | Assign nodes to the graphic slot to set a graphic media of any kind (e.g. image, illustration etc). |
| icon | The preferred way to add an icon to the component. |