Avatar
A circular identity image with initials and an optional presence dot.
import { Avatar } from '@elluzion/iv-ui'; 01 Preview
Sizes
xs, sm, md, and lg steps.
AL GH AT KJ
Source· svelte Show Hide
<script lang="ts">
import { Avatar } from '@elluzion/iv-ui';
</script>
<div class="row">
<Avatar size="xs" fallback="AL" alt="Ada Lovelace" />
<Avatar size="sm" fallback="GH" alt="Grace Hopper" />
<Avatar fallback="AT" alt="Alan Turing" />
<Avatar size="lg" fallback="KJ" alt="Katherine Johnson" />
</div>
<style>
.row {
display: flex;
align-items: center;
gap: var(--iv_spacing-md);
}
</style>02 Usage
fallbackinitials show whensrcis missing or fails to load.- Pass an empty
altfor decorative avatars; otherwisealtnames the person. statusadds a presence dot: neutral, success, error, info, or accent.
03 Examples
Fallback
Initials are used when there is no image or the image fails.
AL
Source· svelte Show Hide
<script lang="ts">
import { Avatar } from '@elluzion/iv-ui';
</script>
<div class="row">
<Avatar fallback="AL" alt="Ada Lovelace" />
<Avatar src="data:image/png;base64,invalid" fallback="GH" alt="Grace Hopper" />
<Avatar src="data:image/png;base64,invalid" fallback="AT" alt="Alan Turing" />
</div>
<style>
.row {
display: flex;
align-items: center;
gap: var(--iv_spacing-md);
}
</style>Status
A presence dot in the corner, with every status treatment.
AL GH AT KJ MH
Source· svelte Show Hide
<script lang="ts">
import { Avatar } from '@elluzion/iv-ui';
</script>
<div class="row">
<Avatar fallback="AL" alt="Ada Lovelace" status="success" />
<Avatar fallback="GH" alt="Grace Hopper" status="error" />
<Avatar fallback="AT" alt="Alan Turing" status="info" />
<Avatar fallback="KJ" alt="Katherine Johnson" status="accent" />
<Avatar fallback="MH" alt="Margaret Hamilton" status="neutral" />
</div>
<style>
.row {
display: flex;
align-items: center;
gap: var(--iv_spacing-md);
}
</style>04 API
import { Avatar } from '@elluzion/iv-ui';Props
6 props · 0 events · 1 snippets| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | '' | Image source. Falls back to fallback initials when missing or broken. |
| alt | string | '' | Accessible name for the image. Use an empty string for decorative avatars. |
| size | AvatarSize | 'md' | Control size. |
| fallback | string | '' | Initials shown when there is no image. |
| status | AvatarStatus | — | Presence dot treatment. |
| className | string | '' | Extra classes merged onto the root element. |
class, id, style, aria-*, and data-* are forwarded through rest props.
Snippets
| Snippet | Type | Description |
|---|---|---|
| children | Snippet | Custom avatar content replacing the image. |
Types
AvatarSize
Avatar diameter steps.
type AvatarSize = 'xs' | 'sm' | 'md' | 'lg';AvatarStatus
Presence dot treatments.
type AvatarStatus = 'neutral' | 'success' | 'error' | 'info' | 'accent';05 Accessibility
- When the image is present,
altis its accessible name. - The initials fallback gets
role="img"and the same name whenaltis set. - An empty
altmakes the avatar decorative; use it when the name is already next to the avatar.
06 Tokens & CSS hooks
Tokens used
--iv_accent --iv_avatar-lg --iv_avatar-md --iv_avatar-sm --iv_avatar-xs --iv_border --iv_error --iv_foreground-dim --iv_info --iv_leading-none --iv_radius-pill --iv_spacing-sm --iv_success --iv_surface --iv_surface-elevated --iv_text-base --iv_text-body-sm --iv_text-sm --iv_text-xs --iv_weight-medium
Class hooks
.iv-accent.iv-avatar.iv-avatar-fallback.iv-avatar-img.iv-avatar-overlay.iv-avatar-status.iv-error.iv-info.iv-lg.iv-neutral.iv-sm.iv-success.iv-xs