Skip to content

Avatar



import '@sbddesign/bui-ui/avatar.js'

The avatar will expand to fill the available width, so wrap it in a container sized for your needs.

<div style="width: 64px; height: 64px;">
<bui-avatar text="Alice" size="large"></bui-avatar>
</div>
<div style="width: 64px; height: 64px;">
<bui-avatar text="₿etty" size="large" show-initial></bui-avatar>
</div>
<div style="width: 64px; height: 64px;">
<bui-avatar text="Cat" image-url={catImage.src} image-url-2x={catImage2x.src}></bui-avatar>
</div>
PropertyAttributeTypeRequiredReflectedDescription
imageUrlimage-urlstringNoNoURL of the avatar image
imageUrl2ximage-url-2xstringNoNoURL of the high-resolution (2x) avatar image
texttextstringNoNoText to display (used for initials or fallback)
showInitialshow-initialbooleanNoYesWhether to show the first character of text as initial
sizesizestringNoYesAvatar size: “small”, “medium”, “large”
  • small - Small avatar
  • medium - Medium avatar (default)
  • large - Large avatar
  • Image Priority: If imageUrl is provided, the image will be displayed
  • Fallback: If no image is provided, the component will show:
    • The first character of text if showInitial is true
    • A generated gradient background based on the text value
  • High Resolution: imageUrl2x is used for high-DPI displays when available

The avatar component does not emit custom events. It behaves as a standard HTML element.