AvatarImage
Profile image slot inside `Avatar` — renders `src` and triggers the fallback on load failure.
Profile image slot inside <Avatar> — renders src and triggers the fallback on load failure.
import { AvatarImage } from "@tetherto/mdk-react-devkit";AvatarImage exposes no documented props.
Usage
Composable image avatar with an automatic fallback. Wraps Radix UI @radix-ui/react-avatar.
Exports
| Name | Description |
|---|---|
Avatar | Root container (mdk-avatar) |
AvatarImage | The <img> element (mdk-avatar__image) |
AvatarFallback | Content shown while the image is loading or fails (mdk-avatar__fallback) |
All three components accept a className prop and forward their ref. All native Radix props are also passed through.
Notes
AvatarFallbackis only rendered while the image is loading or when the image fails to load; Radix handles the visibility automatically.- Size and shape are controlled via CSS — apply utility classes or override
mdk-avatardimensions via CSS variables.
Example
/** * Runnable example for Avatar. */import { Avatar, AvatarFallback, AvatarImage } from '@tetherto/mdk-react-devkit'export const AvatarExample = () => ( <div className="mdk-example-row"> <Avatar> <AvatarImage src="https://i.pravatar.cc/40?img=1" alt="Alice" /> <AvatarFallback>AL</AvatarFallback> </Avatar> <Avatar> <AvatarImage src="https://i.pravatar.cc/40?img=2" alt="Bob" /> <AvatarFallback>BO</AvatarFallback> </Avatar> {/* Fallback shown when image fails to load */} <Avatar> <AvatarImage src="/broken-url.png" alt="Charlie" /> <AvatarFallback>CH</AvatarFallback> </Avatar> </div>)