1. framework components
  2. avatar

Avatar

An image with a fallback for representing the user.

SK
SK
SK

Fallback

Use a fallback when an image fails to load or is unavailable.

SK

Filter

Apply SVG Filters to avatar images.

SK

Anatomy

Here’s an overview of how the Avatar component is structured in code:

svelte
<script lang="ts">
	import { Avatar } from '@skeletonlabs/skeleton-svelte';
</script>

<Avatar>
	<Avatar.Image />
	<Avatar.Fallback />
</Avatar>

API Reference

Root

Prop Default Type
onStatusChange ((details: StatusChangeDetails) => void) | undefined

Functional called when the image loading status changes.

ids Partial<{ root: string; image: string; fallback: string; }> | undefined

The ids of the elements in the avatar. Useful for composition.

getRootNode (() => ShadowRoot | Node | Document) | undefined

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

dir "ltr" "ltr" | "rtl" | undefined

The document's text/writing direction.

element Snippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Provider

Prop Default Type
value () => AvatarApi<PropTypes>

element Snippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Context

Prop Default Type
children Snippet<[() => AvatarApi<PropTypes>]>

Image

Prop Default Type
element Snippet<[HTMLAttributes<"img">]> | undefined

Render the element yourself

Fallback

Prop Default Type
element Snippet<[HTMLAttributes<"span">]> | undefined

Render the element yourself

View page on GitHub