Skip to content
GitHub11 stars

An image element with a fallback for representing the user.

BX ER
BX LR ER
+3
<div class="flex flex-row flex-wrap items-center gap-6 md:gap-12">
    <Avatar>
        <AvatarImage Src="https://avatar.vercel.sh/blazix" alt="@("@blazix")" Class="grayscale" />

Installation

dnx Blazix.Cli add avatar

Usage

<Avatar>
    <AvatarImage Src="https://avatar.vercel.sh/blazix" />
    <AvatarFallback>BX</AvatarFallback>
</Avatar>

Composition

Use the following composition to build an Avatar:

Avatar
├── AvatarImage
├── AvatarFallback
└── AvatarBadge

Use the following composition to build an AvatarGroup:

AvatarGroup
├── Avatar
│   ├── AvatarImage
│   ├── AvatarFallback
│   └── AvatarBadge
├── Avatar
│   ├── AvatarImage
│   ├── AvatarFallback
│   └── AvatarBadge
└── AvatarGroupCount

Basic

A basic avatar component with an image and a fallback.

BX
<Avatar>
    <AvatarImage Src="https://avatar.vercel.sh/blazix" alt="@("@blazix")" Class="grayscale" />
    <AvatarFallback>BX</AvatarFallback>
</Avatar>

Badge

Use the AvatarBadge component to add a badge to the avatar. The badge is positioned at the bottom right of the avatar.

BX
<Avatar>
    <AvatarImage Src="https://avatar.vercel.sh/blazix" alt="@("@blazix")" />
    <AvatarFallback>BX</AvatarFallback>
    <AvatarBadge Class="bg-green-600 dark:bg-green-800" />
</Avatar>

Use the Class parameter to add custom styles to the badge such as custom colors, sizes, etc.

<Avatar>
    <AvatarImage Src="https://avatar.vercel.sh/blazix" alt="@("@blazix")" />
    <AvatarFallback>BX</AvatarFallback>
    <AvatarBadge Class="bg-green-600 dark:bg-green-800" />
</Avatar>

Badge with Icon

You can also use an icon inside <AvatarBadge>.

PP
<Avatar Class="grayscale">
    <AvatarImage Src="https://github.com/pranathip.png" alt="@("@pranathip")" />
    <AvatarFallback>PP</AvatarFallback>
    <AvatarBadge><Icon Data="LucideIcons.Plus" /></AvatarBadge>
</Avatar>

Avatar Group

Use the AvatarGroup component to add a group of avatars.

BX LR ER
<AvatarGroup Class="grayscale">
    <Avatar>
        <AvatarImage Src="https://avatar.vercel.sh/blazix" alt="@("@blazix")" />

Avatar Group Count

Use <AvatarGroupCount> to add a count to the group.

BX LR ER
+3
<AvatarGroup Class="grayscale">
    <Avatar>
        <AvatarImage Src="https://avatar.vercel.sh/blazix" alt="@("@blazix")" />

Avatar Group with Icon

You can also use an icon inside <AvatarGroupCount>.

BX LR ER
<AvatarGroup Class="grayscale">
    <Avatar>
        <AvatarImage Src="https://avatar.vercel.sh/blazix" alt="@("@blazix")" />

Sizes

Use the Size parameter to change the size of the avatar.

BX BX BX
<div class="flex flex-wrap items-center gap-2 grayscale">
    <Avatar Size="AvatarSize.Sm">
        <AvatarImage Src="https://avatar.vercel.sh/blazix" alt="@("@blazix")" />

You can use the Avatar component as a trigger for a dropdown menu.

<DropdownMenu>
    <DropdownMenuTrigger>
        <Render>

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

BX ER
BX LR ER
+٣
<div class="flex flex-row flex-wrap items-center gap-6 md:gap-12">
    <Avatar>
        <AvatarImage Src="https://avatar.vercel.sh/blazix" alt="@("@blazix")" Class="grayscale" />

API Reference

Avatar

ParameterTypeDefault
Render RenderFragment<AvatarRenderProps>? -
Size AvatarSize AvatarSize.Default
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

AvatarBadge

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

AvatarFallback

ParameterTypeDefault
Render RenderFragment<AvatarRenderProps>? -
Delay int 0
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

AvatarGroup

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

AvatarGroupCount

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

AvatarImage

ParameterTypeDefault
Render RenderFragment<AvatarRenderProps>? -
Src string? -
OnLoadingStatusChange EventCallback<ImageLoadingStatus> -
KeepMounted bool false
Class string? -

Other attributes are passed to the element it renders.