Avatar
Alignment target:@astryxdesign/core v0.7.1 · Avatar
<Avatar
name="Ada Lovelace"
size="lg"
shape="circle"
/>Avatar Props #
| Name | Type | Default | Description |
|---|---|---|---|
src | string | - | The avatar image URL. |
fallbackSrc | string | - | Backup image URL used when the primary image fails to load. |
name | string | - | User name. Used for initials fallback and accessible labeling. |
alt | string | - | Accessible label. Takes precedence over name. |
size | AvatarSize | '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. |
shape | AvatarShape | 'circle' | Avatar shape: circle, rounded, or square. |
href | string | - | Makes the avatar a link. |
as | LinkRoot | - | Link root used when href is set. It receives href and to. Without an address the avatar stays a button or a span. |
target | string | - | Browsing context of the link. Applies only when href is set. |
rel | string | - | Link relationship. noopener noreferrer is added when target is _blank. |
Named sizes #
| Name | Pixel value |
|---|---|
xsm | 20px |
sm | 24px |
md | 36px |
lg | 48px |
xl | 128px |
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 #
| Name | Description |
|---|---|
default | Custom content that replaces the default person icon. Only used when there is no image and no name. |
status | Status indicator placed at the corner of the avatar, typically an AvatarStatusDot. |
Avatar Events #
| Name | Description |
|---|---|
error | Emitted when the primary image fails to load. |
AvatarStatusDot Props #
| Name | Type | Default | Description |
|---|---|---|---|
variant | AvatarStatusDotVariant | '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. |
label | string | — | 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.