Epicenter
Local-first, open source apps
CN
ER
CN
LR
ER
+3
Installation
Install bits-ui:
Copy and paste the following code into your project.
Usage
<script lang="ts">
import * as Avatar from "$lib/components/ui/avatar/index.js";
</script> <Avatar.Root>
<Avatar.Image src="https://github.com/shadcn.png" alt="@shadcn" />
<Avatar.Fallback>CN</Avatar.Fallback>
</Avatar.Root> Basic
A basic avatar component with an image and a fallback.
CN
Badge
Use the Avatar.Badge component to add a badge to the avatar. The badge is positioned at the bottom right of the avatar.
CN
Use the class prop to add custom styles to the badge such as custom colors, sizes, etc.
<Avatar.Root>
<Avatar.Image src="https://github.com/shadcn.png" alt="@shadcn" />
<Avatar.Fallback>CN</Avatar.Fallback>
<Avatar.Badge class="bg-green-600 dark:bg-green-800" />
</Avatar.Root> Badge with Icon
You can also use an icon inside <Avatar.Badge>.
PP
Avatar Group
Use the Avatar.Group component to add a group of avatars.
CN
LR
ER
Avatar Group Count
Use <Avatar.GroupCount> to add a count to the group.
CN
LR
ER
+3
Avatar Group with Icon
You can also use an icon inside <Avatar.GroupCount>.
CN
LR
ER
Sizes
Use the size prop to change the size of the avatar.
CN
CN
CN
Dropdown
You can use the Avatar component as a trigger for a dropdown menu.