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:

tsx
import { Avatar } from '@skeletonlabs/skeleton-react';

export default function Anatomy() {
	return (
		<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.

element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Provider

PropDefaultType
valueAvatarApi<PropTypes>

element((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Context

PropDefaultType
children(avatar: AvatarApi<PropTypes>) => ReactNode

Image

txt
w-full object-cover
PropDefaultType
element((attributes: HTMLAttributes<"img">) => Element) | undefined

Render the element yourself

Fallback

txt
size-full flex justify-center items-center
PropDefaultType
element((attributes: HTMLAttributes<"span">) => Element) | undefined

Render the element yourself

View page on GitHub