Skip to content
Focsd homeFocsd homeFocsd
Forms

Avatar

A person or entity, as a photo or initials.

  • Tag: focsd-avatar
  • Pattern: Img with text fallback
  • Category: Display

Example

HTML
<focsd-avatar name="Amara Okafor"></focsd-avatar>
<focsd-avatar name="Lukas Brandt" size="l"></focsd-avatar>
<focsd-avatar name="Priya Raman" size="s"></focsd-avatar>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-avatar.js';
</script>
<focsd-avatar name="Amara Okafor"></focsd-avatar>

API

Attributes

AttributePropertyTypeDefault
srcsrcstring—
namenamestring—
sizesize's' | 'm' | 'l'm
decorativedecorativebooleanfalse

CSS parts

Style the inside of the component with ::part(), for example focsd-avatar::part(avatar).

PartDescription
avatarThe avatar element.
imageThe image element.
initialsThe initials shown when there is no image.

Accessibility

  • role="img" named by name; falls back to initials when there is no image or it fails.
  • Add decorative when the name is already shown next to it.