Avatar

Alignment target:@astryxdesign/core v0.7.1 · Avatar

<Avatar
  name="Ada Lovelace"
  size="lg"
  shape="circle"
/>

Avatar Props #

NameTypeDefaultDescription
srcstring-The avatar image URL.
fallbackSrcstring-Backup image URL used when the primary image fails to load.
namestring-User name. Used for initials fallback and accessible labeling.
altstring-Accessible label. Takes precedence over name.
sizeAvatarSize'md'Avatar size: a named size or one of the numeric pixel values listed below. Inside an AvatarGroup the group's size always wins, including the group's default.
shapeAvatarShape'circle'Avatar shape: circle, rounded, or square.
hrefstring-Makes the avatar a link.
asLinkRoot-Link root used when href is set. It receives href and to. Without an address the avatar stays a button or a span.
targetstring-Browsing context of the link. Applies only when href is set.
relstring-Link relationship. noopener noreferrer is added when target is _blank.

Named sizes #

NamePixel value
xsm20px
sm24px
md36px
lg48px
xl128px

Numeric sizes #

A numeric size must be one of the pixel values the AvatarSize type lists:

16 | 20 | 24 | 32 | 36 | 40 | 48 | 60 | 64 | 72 | 96 | 128 | 144 | 180

Any other number is a type error.

Avatar Slots #

NameDescription
defaultCustom content that replaces the default person icon. Only used when there is no image and no name.
statusStatus indicator placed at the corner of the avatar, typically an AvatarStatusDot.

Avatar Events #

NameDescription
errorEmitted when the primary image fails to load.

AvatarStatusDot Props #

NameTypeDefaultDescription
variantAvatarStatusDotVariant'success'Semantic status: success (filled dot), neutral (hollow ring), or error (dot with a minus bar). info and warning are older names and still draw as success and error.
labelstring—Accessible name for the status, composed into the avatar's own name (Jane Doe, Online).

Native attributes #

The root is a <span> by default. With href it is an <a> or the component passed to as. A click listener without an address makes it a <button>.

The following are passed to the root element:

  • HTML attributes.
  • aria-* attributes.
  • data-* attributes.
  • class.
  • style.