- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Menubar
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Typography
Installation#
pnpm dlx shadcn@latest add @force-ui-svelte/avatar
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>Composition#
Use the following composition to build an Avatar:
Avatar.Root
├── Avatar.Image
├── Avatar.Fallback
└── Avatar.BadgeUse the following composition to build an Avatar.Group:
Avatar.Group
├── Avatar.Root
│ ├── Avatar.Image
│ ├── Avatar.Fallback
│ └── Avatar.Badge
├── Avatar.Root
│ ├── Avatar.Image
│ ├── Avatar.Fallback
│ └── Avatar.Badge
└── Avatar.GroupCountExamples#
Basic#
A basic avatar component with an image and a fallback.
Badge#
Use the Avatar.Badge component to add a badge to the avatar. The badge is positioned at the bottom right of the avatar.
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>.
Avatar Group#
Use the Avatar.Group component to add a group of avatars.
Avatar Group Count#
Use <Avatar.GroupCount> to add a count to the group.
Avatar Group with Icon#
You can also use an icon inside <Avatar.GroupCount>.
Sizes#
Use the size prop to change the size of the avatar.
Dropdown#
You can use the Avatar.Root component as a trigger for a dropdown menu.
RTL#
To enable RTL support in Force UI, see the RTL configuration guide.
API Reference#
Avatar.Root#
The Avatar.Root component is the root component that wraps the avatar image and fallback.
| Prop | Type | Default |
|---|---|---|
size | "default" | "sm" | "lg" | "default" |
class | string | - |
Avatar.Image#
The Avatar.Image component displays the avatar image.
| Prop | Type | Default |
|---|---|---|
src | string | - |
alt | string | - |
class | string | - |
Avatar.Fallback#
The Avatar.Fallback component displays a fallback when the image fails to load.
| Prop | Type | Default |
|---|---|---|
class | string | - |
Avatar.Badge#
The Avatar.Badge component displays a badge indicator on the avatar, typically positioned at the bottom right.
| Prop | Type | Default |
|---|---|---|
class | string | - |
Avatar.Group#
The Avatar.Group component displays a group of avatars with overlapping styling.
| Prop | Type | Default |
|---|---|---|
class | string | - |
Avatar.GroupCount#
The Avatar.GroupCount component displays a count indicator in an avatar group, typically showing the number of additional avatars.
| Prop | Type | Default |
|---|---|---|
class | string | - |