Skip to content
On this page

NcAvatar

Props

Prop nameDescriptionTypeValuesDefault
urlSet a custom url to the avatar image
either the url, user or displayName property must be defined
string-undefined
iconClassSet a css icon-class for an icon to be used instead of the avatar.string-undefined
userSet the user id to fetch the avatar
either the url, user or displayName property must be defined
string-undefined
showUserStatusWhether or not to display the user-statusboolean-true
showUserStatusCompactWhether or not to the status-icon should be used instead of online/awayboolean-true
preloadedUserStatusWhen the user status was preloaded via another source it can be handed in with this property to save the request.
If this property is not set the status will be fetched automatically.
If a preloaded no-status is available provide this object with properties "status", "icon" and "message" set to null.
object-undefined
isGuestIs the user a guest user (then we have to user a different endpoint)boolean-false
displayNameSet a display name that will be rendered as a tooltip
either the url, user or displayName property must be defined
specify just the displayname to generate a placeholder avatar without
trying to fetch the avatar based on the user id
string-undefined
sizeSet a size in px for the rendered avatarnumber-32
allowPlaceholderPlaceholder avatars will be automatically generated when this is set to trueboolean-true
disableTooltipDisable the tooltipboolean-false
disableMenuDisable the menuboolean-false
tooltipMessageDeclares a custom tooltip when not null
Fallback will be the displayName

requires disableTooltip not to be set to true
string-null
isNoUserDeclares username is not a user's name, when true.
Prevents loading user's avatar from server and forces generating colored initials,
i.e. if the user is a group
boolean-false
menuPositionChoose the avatar menu alignment.
Possible values are left, center, right.
string-'center'
menuContainerSelector for the popover menu containerstring|object|Element|boolean-'body'
ariaLabelstring-null

Slots

NameDescriptionBindings
iconIcon slot

Basic user avatar

vue
<NcAvatar user="willywonka" display-name="Willy Wonka" />

Avatar with image

vue
<NcAvatar
  url="https://nextcloud.com/wp-content/themes/next/assets/img/common/nextcloud-square-logo.png"
/>

Avatar with material design icon

 <template>
	<NcAvatar>
		<template #icon>
			<AccountMultiple :size="20" />
		</template>
	</NcAvatar>
</template>
<script>
import AccountMultiple from 'vue-material-design-icons/AccountMultiple'

export default {
	components: {
		AccountMultiple,
	},
 }
 </script>

Avatar with preloaded status

 <template>
	<NcAvatar user="janedoe"
		display-name="Jane Doe"
		:preloaded-user-status="status">
	</NcAvatar>
</template>
<script>

export default {
	data() {
		return {
			status: {
				icon: '',
				status: 'dnd',
				message: 'Not busy',
			},
		}
	},
 }
 </script>

Avatar for non-users

vue
<NcAvatar display-name="Robbie Hyeon-Jeong" :is-no-user="true" />

Avatar on complex background

<template>
	<div class="avatar-background">
		<NcAvatar class="avatar" :is-no-user="true" display-name="Cecilia Rohese" />
	</div>
</template>
<style scoped>
.avatar-background {
	width: 80px;
	height: 60px;
	background: linear-gradient(to bottom, #0057b8 0%, #0057b8 49.99%, #ffd700 50%, #ffd700 100%);
}

.avatar {
	margin: 15px 25px;
}
</style>