Copy to clipboard
Installation
Copy to clipboard
npx bearnie add avatar
npx bearnie add avatar
bunx bearnie add avatar
bunx bearnie add avatar
pnpm dlx bearnie add avatar
pnpm dlx bearnie add avatar
yarn dlx bearnie add avatar
yarn dlx bearnie add avatar
Copy to clipboard
import Avatar from "@/components/ui/avatar/Avatar.astro";
import AvatarImage from "@/components/ui/avatar/AvatarImage.astro";
import AvatarFallback from "@/components/ui/avatar/AvatarFallback.astro";
Usage
import {
Avatar,
AvatarImage,
AvatarFallback,
} from "@/components/ui/avatar"
<Avatar>
<AvatarImage src="/images/avatars/user.png" alt="User" />
<AvatarFallback>MA</AvatarFallback>
</Avatar>
Examples
Sizes
Copy to clipboard
SM MD LG
With fallback
Copy to clipboard
JD Avatar group
Copy to clipboard
Avatar group with max
Copy to clipboard
Anatomy
Avatar- The root container with size variantsAvatarImage- The profile imageAvatarFallback- Displayed when image fails to loadAvatarGroup- Groups avatars with optional max limit
Props
Avatar
| Prop | Type | Default | Description |
|---|---|---|---|
| size | sm | default | lg | default | Avatar size |
| class | string | - | Additional CSS classes |
AvatarImage
| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | required | Image source URL |
| alt | string | required | Alt text for accessibility |
| class | string | - | Additional CSS classes |
AvatarFallback
| Prop | Type | Default | Description |
|---|---|---|---|
| class | string | - | Additional CSS classes |
AvatarGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| max | number | - | Maximum avatars to show before overflow indicator |
| size | sm | default | lg | default | Size for overflow indicator |
| class | string | - | Additional CSS classes |