Avatar for Astro
Astro profile images and text fallbacks in a shared size system.
Installation
bunx --bun shadcn@latest add @gnostic/avatarnpx shadcn@latest add @gnostic/avatarpnpm dlx shadcn@latest add @gnostic/avatarCopy the files
src/components/ui/avatar/avatar-badge.astrosrc/components/ui/avatar/avatar-fallback.astrosrc/components/ui/avatar/avatar-group-count.astrosrc/components/ui/avatar/avatar-group.astrosrc/components/ui/avatar/avatar-image.astrosrc/components/ui/avatar/avatar.astrosrc/components/ui/avatar/index.ts
Usage
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
<Avatar>
<AvatarImage src="/avatar.jpg" alt="Team member" />
<AvatarFallback>TM</AvatarFallback>
</Avatar>
Composition
Arrange the parts as shown for an Avatar:
Avatar
├── AvatarImage
├── AvatarFallback
└── AvatarBadge
Arrange the parts as shown for an AvatarGroup:
AvatarGroup
├── Avatar
│ ├── AvatarImage
│ ├── AvatarFallback
│ └── AvatarBadge
├── Avatar
│ ├── AvatarImage
│ ├── AvatarFallback
│ └── AvatarBadge
└── AvatarGroupCount
Examples
Fallback
Use AvatarFallback when an image is unavailable or intentionally omitted.
Group
Use AvatarGroup when you need overlapping participant or collaborator lists.
Notes
- Always include
AvatarFallbackso initials or placeholder content remain visible when the image fails to load. - Use size variants on
Avatarinstead of custom width and height classes when possible.
API Reference
Read the installed source for the complete prop types.
When to use Avatar
Use Avatar beside a person or team name. Put AvatarImage and AvatarFallback inside the same root. Use initials or a short mark for the fallback, and choose one size for a row of related people.
Keyboard and behavior
Supply meaningful image alternative text if the image conveys identity that is absent from nearby text. Use empty alt text when the adjacent name already supplies it. This Astro version does not include Base UI image loading state; a broken image URL does not automatically switch to the fallback.
Theme and layout
The root clips content to its rounded shape and the fallback uses muted colors. Check long initials and transparent logos in both modes. Resolve an absent image in your data before rendering when you need a reliable fallback.