Display an image or initials as an avatar.
import { Avatar } from '@fluxui-dev/react';<Avatar src="https://unavatar.io/x/calebporzio" />
Use the tooltip prop to display a tooltip when hovering over the avatar.
<Avatar tooltip="Caleb Porzio" src="https://unavatar.io/x/calebporzio" />{/* Or infer from the name prop... */}<Avatar tooltip name="Caleb Porzio" src="https://unavatar.io/x/calebporzio" />
When no src is provided, the name prop will be used to automatically generate initials. You can also use the initials prop directly.
<Avatar name="Caleb Porzio" /><Avatar name="calebporzio" /><Avatar name="calebporzio" initialsSingle />{/* Or use the initials prop directly... */}<Avatar initials="CP" />
Use the size prop to change the size of the avatar.
{/* Extra large: size-16 (64px) */}<Avatar size="xl" src="https://unavatar.io/x/calebporzio" />{/* Large: size-12 (48px) */}<Avatar size="lg" src="https://unavatar.io/x/calebporzio" />{/* Default: size-10 (40px) */}<Avatar src="https://unavatar.io/x/calebporzio" />{/* Small: size-8 (32px) */}<Avatar size="sm" src="https://unavatar.io/x/calebporzio" />{/* Extra small: size-6 (24px) */}<Avatar size="xs" src="https://unavatar.io/x/calebporzio" />
Use the icon prop to display an icon instead of an image.
import { ComputerDesktopIcon, PhoneIcon, UserIcon } from '@fluxui-dev/react/icons';<Avatar icon={UserIcon} /><Avatar icon={PhoneIcon} /><Avatar icon={ComputerDesktopIcon} />
Use the color prop to change the color of the avatar.
<Avatar name="Caleb Porzio" color="red" /><Avatar name="Caleb Porzio" color="orange" /><Avatar name="Caleb Porzio" color="amber" /><Avatar name="Caleb Porzio" color="yellow" /><Avatar name="Caleb Porzio" color="lime" /><Avatar name="Caleb Porzio" color="green" /><Avatar name="Caleb Porzio" color="emerald" /><Avatar name="Caleb Porzio" color="teal" /><Avatar name="Caleb Porzio" color="cyan" /><Avatar name="Caleb Porzio" color="sky" /><Avatar name="Caleb Porzio" color="blue" /><Avatar name="Caleb Porzio" color="indigo" /><Avatar name="Caleb Porzio" color="violet" /><Avatar name="Caleb Porzio" color="purple" /><Avatar name="Caleb Porzio" color="fuchsia" /><Avatar name="Caleb Porzio" color="pink" /><Avatar name="Caleb Porzio" color="rose" />
Deterministically generate a color based on a user's name. Pass colorSeed, such as the user's ID, to keep the color when the name changes.
<Avatar name="Caleb Porzio" color="auto" />{/* Use colorSeed to generate a consistent color based */}{/* on something unchanging like a user's ID... */}<Avatar name="Caleb Porzio" color="auto" colorSeed={user.id} />
Use the circle prop to make the avatar circular.
<Avatar circle src="https://unavatar.io/x/calebporzio" />
Add badges to avatars in various ways. Use the badge prop by itself for a simple dot indicator, provide content like numbers or emojis, or even pass in your own element. Pass an Avatar.Badge element to set the badge's color, shape, position, or variant.
<Avatar badge={<Avatar.Badge color="green" />} src="https://unavatar.io/x/calebporzio" /><Avatar badge={<Avatar.Badge color="zinc" position="top right" circle variant="outline" />} src="https://unavatar.io/x/calebporzio" /><Avatar badge="25" src="https://unavatar.io/x/calebporzio" /><Avatar circle badge={<Avatar.Badge circle>👍</Avatar.Badge>} src="https://unavatar.io/x/calebporzio" /><Avatar circle src="https://unavatar.io/x/calebporzio" badge={<img className="size-3" src="https://unavatar.io/github/hugosaintemarie" alt="" />} />
Stack avatars together. By default, grouped avatars have rings that adapt to your theme - white in light mode and a dark color in dark mode. If you need to customize the ring color, to match a different background, you can do so by adding a custom class to the Avatar.Group component.
<Avatar.Group> <Avatar src="https://unavatar.io/x/calebporzio" /> <Avatar src="https://unavatar.io/github/hugosaintemarie" /> <Avatar src="https://unavatar.io/github/joshhanley" /> <Avatar>3+</Avatar></Avatar.Group>{/* Adapt rings to custom background... */}<Avatar.Group className="**:ring-zinc-100 dark:**:ring-zinc-800"> <Avatar circle src="https://unavatar.io/x/calebporzio" /> <Avatar circle src="https://unavatar.io/github/hugosaintemarie" /> <Avatar circle src="https://unavatar.io/github/joshhanley" /> <Avatar circle>3+</Avatar></Avatar.Group>
Pass render={<button type="button" />} to make the avatar a button, including type="button" so it does not submit a surrounding form.
<Avatar render={<button type="button" />} name="Caleb Porzio" src="https://unavatar.io/x/calebporzio" />
Use the href prop to make the avatar a link.
<Avatar href="https://x.com/calebporzio" name="Caleb Porzio" src="https://unavatar.io/x/calebporzio" />
import { Avatar, Heading, Text } from '@fluxui-dev/react';import { StarIcon } from '@fluxui-dev/react/icons';<div> <div className="flex items-center gap-2"> <StarIcon variant="solid" /> <StarIcon variant="solid" /> <StarIcon variant="solid" /> <StarIcon variant="solid" /> <StarIcon variant="solid" /> </div> <Heading size="xl" className="mt-4 italic"> <p>IMO Livewire takes Blade to the next level. It's basically what Blade should be by default. 🔥</p> </Heading> <div className="mt-6 flex items-center gap-4"> <Avatar size="lg" src="https://unavatar.io/x/taylorotwell" /> <div> <Heading size="lg">Taylor Otwell</Heading> <Text>Creator of Laravel</Text> </div> </div></div>
import { Avatar, Badge, Heading, Text } from '@fluxui-dev/react';<div> <Heading size="xl">The Laravel Podcast <Badge inset="top bottom" className="ml-1 max-sm:hidden">New</Badge></Heading> <Text className="mt-2"> A podcast about Laravel, development best practices, and the PHP ecosystem—hosted by Jeffrey Way, Matt Stauffer, and Taylor Otwell, later joined by Adam Wathan. </Text> <Avatar.Group className="mt-6"> <Avatar circle size="lg" src="https://unavatar.io/x/taylorotwell" /> <Avatar circle size="lg" src="https://unavatar.io/x/adamwathan" /> <Avatar circle size="lg" src="https://unavatar.io/x/jeffrey_way" /> <Avatar circle size="lg" src="https://unavatar.io/x/stauffermatt" /> </Avatar.Group></div>
Include avatars in lists to make user data more identifiable.
import { Avatar, Button, Card, Heading, Separator } from '@fluxui-dev/react';import { PlusIcon } from '@fluxui-dev/react/icons';<Card> <div className="flex items-center justify-between"> <Heading>Assignees</Heading> <Button size="sm" variant="subtle" icon={PlusIcon} inset="top bottom" aria-label="Add assignee" /> </div> <Separator className="mt-2 mb-4" variant="subtle" /> <ul className="flex flex-col gap-3"> <li className="flex items-center gap-2"> <Avatar size="xs" src="https://unavatar.io/github/calebporzio" /> <Heading>Caleb Porzio</Heading> </li> <li className="flex items-center gap-2"> <Avatar size="xs" src="https://unavatar.io/github/hugosaintemarie" /> <Heading>Hugo Sainte-Marie</Heading> </li> <li className="flex items-center gap-2"> <Avatar size="xs" src="https://unavatar.io/github/joshhanley" /> <Heading>Josh Hanley</Heading> </li> <li className="flex items-center gap-2"> <Avatar size="xs" src="https://unavatar.io/github/jasonlbeggs" /> <Heading>Jason Beggs</Heading> </li> </ul></Card>
|
Prop
|
Description
|
|---|---|
| name |
User's name to display as initials. If provided without initials, this will be used to generate initials automatically.
|
| src |
URL to the image to display as avatar. While it loads, or if it fails, the initials or icon show instead.
|
| initials |
Custom initials to display when no src is provided. Will override name if provided.
|
| initialsSingle |
If true, generates a single initial from name instead of two.
|
| alt |
Alternative text for the avatar image. (Default: name if provided)
|
| size |
Size of the avatar. Options: xs (24px), sm (32px), md (default, 40px), lg (48px), xl (64px).
|
| color |
Background color when displaying initials or icons. Options: zinc and gray, which match the default, or red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, auto. Default: none (uses system colors).
|
| colorSeed |
Value used when color="auto" to deterministically generate consistent colors. Useful for using user IDs to generate consistent colors.
|
| circle |
If true, makes the avatar fully circular instead of rounded corners.
|
| icon |
Icon to display instead of an image or initials: a component, such as UserIcon from @fluxui-dev/react/icons, or an element.
|
| iconVariant |
Icon variant to use. Options: outline, solid, mini, micro. Default: solid.
|
| tooltip |
Content to display in a tooltip when hovering over the avatar. If set to true, uses the name prop as tooltip content. Pass a Tooltip element without children, such as <Tooltip position="bottom" />, to set its options. Without its own content, it shows name.
|
| badge |
Content to display as a badge: true for a dot, a string or number, an Avatar.Badge element to style it, or any other element, shown inside the default badge.
|
| href |
URL to link to, making the avatar a link element. An in-app URL navigates through the link registered in FluxProvider.
|
| target |
Where the link opens, such as _blank. Pass it with href, as you would rel and download. A target other than _self or a download renders a plain a tag.
|
| render |
Element to render instead (such as <button type="button" />), with the avatar's props merged in. Replaces the span, or the a that href chooses.
|
| children |
Custom content to display inside the avatar, such as 3+. initials and name take precedence.
|
|
CSS
|
Description
|
|---|---|
| className |
Additional CSS classes applied to the avatar.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-avatar |
Applied to the root element for styling and identification.
|
| data-size |
The avatar's size, such as md.
|
| data-circle |
Applied when the avatar is circular.
|
|
CSS
|
Description
|
|---|---|
| className |
CSS classes to apply to the group, including customizing ring colors using **:ring-{color} format.
|
|
Prop
|
Description
|
|---|---|
| children |
Place multiple Avatar components here to display them as a group.
|
The badge Avatar renders for its badge prop. Pass it as badge to set its color, shape, position, or variant. It takes the avatar's size.
|
Prop
|
Description
|
|---|---|
| color |
Color of the badge: any of the 17 named colors, or zinc (gray is the same). Without it, the badge is white, or zinc-900 in dark mode.
|
| circle |
If true, makes the badge fully circular instead of slightly rounded corners.
|
| position |
Corner of the badge. Options: top left, top right, bottom left, bottom right. Default: bottom right.
|
| variant |
Variant of the badge. Options: solid, outline. Default: solid.
|
| children |
Content of the badge, such as a number or an emoji. Leave it empty for a dot.
|
|
CSS
|
Description
|
|---|---|
| className |
Additional CSS classes applied to the badge.
|