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

txt
isolate bg-surface-400-600 size-16 rounded-full overflow-hidden
PropDefaultType
onStatusChange((details: StatusChangeDetails) => void) | undefined

Functional called when the image loading status changes.

idsPartial<{ 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.

elementSnippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Provider

PropDefaultType
value() => AvatarApi<PropTypes>

elementSnippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Context

PropDefaultType
childrenSnippet<[() => AvatarApi<PropTypes>]>

Image

txt
w-full object-cover
PropDefaultType
elementSnippet<[HTMLAttributes<"img">]> | undefined

Render the element yourself

Fallback

txt
size-full flex justify-center items-center
PropDefaultType
elementSnippet<[HTMLAttributes<"span">]> | undefined

Render the element yourself

View page on GitHub