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

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 ((attributes: HTMLAttributes<"div">) => Element) | undefined

Render the element yourself

Provider

Prop Default Type
value AvatarApi<PropTypes>

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

Render the element yourself

Context

Prop Default Type
children (avatar: AvatarApi<PropTypes>) => ReactNode

Image

Prop Default Type
element ((attributes: HTMLAttributes<"img">) => Element) | undefined

Render the element yourself

Fallback

Prop Default Type
element ((attributes: HTMLAttributes<"span">) => Element) | undefined

Render the element yourself

View page on GitHub