Skip to content
iv-ui v0.3.0

Avatar

since 0.2.0

A circular identity image with initials and an optional presence dot.

import { Avatar } from '@elluzion/iv-ui';

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>
  • fallback initials show when src is missing or fails to load.
  • Pass an empty alt for decorative avatars; otherwise alt names the person.
  • status adds a presence dot: neutral, success, error, info, or accent.

Fallback

Initials are used when there is no image or the image fails.

AL Grace Hopper Alan Turing
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>
import { Avatar } from '@elluzion/iv-ui';

Props

6 props · 0 events · 1 snippets
PropTypeDefaultDescription
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

SnippetTypeDescription
childrenSnippetCustom 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';
  • When the image is present, alt is its accessible name.
  • The initials fallback gets role="img" and the same name when alt is set.
  • An empty alt makes the avatar decorative; use it when the name is already next to the avatar.
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
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records