enes

Avatar

An Avatar is a graphical representation of a user, team, or entity.

Avatar can display an image, icon, or initials, and supports different sizes, shapes, and status indicators.

Usage

<script>
	import { Avatar } from 'fluentui-svelte';
</script>

<Avatar size={40} name="FluentUI Svelte" />

Component API

A brief explanation of the props that really need explaining. You can see the rest of the props here.

Image

An avatar can display an image. It is recommended to also include a name in addition to the image: the initials from the name are displayed while the image is loading, and the name makes the Avatar accessible to screen readers.

Icon

An avatar can display an icon. The icon will only be shown when there is no image or initials available.

Badge

An avatar can have a badge to indicate presence status. See the PresenceBadge component for more info.

Shape

An avatar can have a square, circular, or rounded shape.

Color: colorful

An avatar can have its color automatically picked based on the name prop, or idForColor can be used if a name is not available.

Component Props

NameTypeDescription
namestringThe name of the person or entity represented by this Avatar. Used to determine initials and for accessibility tools.
image{ src: string }The Avatar image. It can only be a single image URL.
refHTMLDivElementThe DOM reference of the avatar element.
sizenumberSize of the avatar in pixels.
shapestringThe shape of the avatar. Possible values: 'circular', 'rounded', 'square'.
colorstringThe color used when displaying either an icon or initials. Supports system colors. Possible values: 'information', 'attention', 'warning', 'success', 'critical', 'colorful'.
activestringOptional activity indicator. Possible values: 'active', 'inactive'. Active decorates the avatar according to activeAppearance. Inactive reduces size and makes it partially transparent.
activeAppearancestringThe appearance used when active is set to active. Possible values: 'ring', 'shadow', 'ring-shadow'.
initialsstringCustom initials. By default, initials are derived from the name prop using the getInitials function. They are displayed when there is no image.
idForColorstringA string used instead of the name to determine the color when color is set to colorful. Useful when a name is unavailable but another unique identifier exists.
iconSnippet | ComponentThe icon to display when the avatar does not have an image or initials.
badgeobjectThe badge to display as a status indicator. It can include a custom icon.