Avatar
stableAn image element with a fallback for representing the user.
Basic usage
JDAB
Examples
Avatar group
Stack avatars with negative margin to form a compact group.
ALGHMHAT
Team stack with fallback
Show loaded images, initials fallbacks and delayed fallback states together.
Features
- Automatic and manual control over when the image renders.
- Fallback accepts an arbitrary node.
- Delays fallback to avoid flicker.
Installation
bash
pnpm dlx structyl add avatarAPI Reference
Avatar.Root
Contains the image and fallback.
| Prop | Type | Default |
|---|---|---|
| asChild | booleanMerge props onto the immediate child instead of rendering a default element. | false |
| className | stringAdditional Tailwind classes, merged with the component defaults. | — |
Avatar.Image
The avatar image. Renders only once loaded successfully.
| Prop | Type | Default |
|---|---|---|
| src | stringImage source URL. | — |
| onLoadingStatusChange | (status: 'idle' | 'loading' | 'loaded' | 'error') => voidCalled when the loading status changes. | — |
| className | stringAdditional Tailwind classes, merged with the component defaults. | — |
Avatar.Fallback
Renders while the image is loading or has failed.
| Prop | Type | Default |
|---|---|---|
| delayMs | numberDelay in ms before showing, to avoid flicker on fast loads. | — |
| className | stringAdditional Tailwind classes, merged with the component defaults. | — |