Avatar
On this page
Photo and initials
Pass name and an optional src. While the image loads or if it fails, the avatar shows fallback, then initials, then initials from name.
TSX
import { Avatar } from "./components/ui/Avatar";
export default function Example() {
return (
<>
<Avatar
name="Avery Brooks"
src="/media-avatar-avery-brooks.jpg"
/>
<Avatar name="Morgan Chen" />
</>
);
}
Sizes and shapes
Set size and shape. The defaults are md and circle.
TSX
import { Avatar } from "./components/ui/Avatar";
export default function Example() {
return (
<>
<Avatar name="Avery Brooks" size="sm" />
<Avatar name="Morgan Chen" size="md" shape="rounded" />
<Avatar name="Jordan Rivera" size="lg" shape="square" />
</>
);
}
Presence
Set status for the indicator dot and statusLabel for a custom accessible label. Show important presence information in text next to the avatar.
TSX
import { Avatar } from "./components/ui/Avatar";
export default function Example() {
return (
<>
<Avatar name="Avery Brooks" size="sm" status="online" />
<Avatar
name="Morgan Chen"
status="away"
statusLabel="Back at 2 PM"
/>
</>
);
}
Tooltip and popover
Hover or focus the first avatar. Click or press Enter on the second. Escape dismisses either. When both props are set, the popover takes precedence.
TSX
import { Avatar } from "./components/ui/Avatar";
export default function Example() {
return (
<>
<Avatar name="Avery Brooks" tooltip />
<Avatar name="Morgan Chen" popover="Project lead" />
</>
);
}
Avatar props
| Prop | Usage |
|---|---|
name |
Required. Provides the default accessible name and generated initials. |
src, alt |
Photo URL and accessible name override. With a tooltip or popover, alt replaces the full trigger name, including status. |
size |
xxs, xs, sm, md, lg, or xl. Default: md. |
shape |
square, rounded, or circle. Default: circle. |
fallback, initials, variant |
Custom fallback content, initials, or color. variant styles the fallback only. Use a semantic color such as primary or a palette value such as teal-300. Default: primary. |
status, statusLabel |
online, away, busy, or offline, with an optional accessible label. |
indicator |
Custom badge or marker, separate from presence. Give a meaningful indicator an accessible label. |
tooltip, popover |
Pass true for built-in content or pass text or JSX. The built-in tooltip includes name and status; the built-in popover shows the name. Do not nest a popover avatar in a link or button. |
decorative |
Hides the avatar from assistive technology and disables its built-in details. Use when the surrounding content already conveys identity and presence. |
imageProps |
Native image props except src, alt, and children. Pass a top-level src even with imageProps.srcSet. |
onLoadingStatusChange |
Receives idle, loading, loaded, or error. |
Avatar group
Pass members with stable IDs. This example shows two people and a +1 marker. Hover or focus the marker to see the third name.
TSX
import { AvatarGroup } from "./components/ui/Avatar";
const members = [
{ id: "avery", name: "Avery Brooks" },
{ id: "morgan", name: "Morgan Chen" },
{ id: "jordan", name: "Jordan Rivera" },
];
export default function Example() {
return (
<AvatarGroup
label="Project collaborators"
members={members}
limit={2}
size="sm"
tooltips
/>
);
}
AvatarGroup props
| Prop | Usage |
|---|---|
label |
Required accessible name for the group. |
members, children |
Pass member objects or compose children. members takes precedence, even when empty. |
limit |
Number of visible entries or direct children. A fragment counts as one child. Use 0 for overflow only, or omit to show all supplied entries. |
total |
Overall count when you have only some members. Cannot reduce the count below the supplied entries. |
size |
Shared size; overrides individual avatar sizes. |
tooltips |
Enables tooltips for direct avatars and the default overflow. Automatic overflow names come from members or direct Avatar children. |
renderOverflow |
Renders a replacement from the hidden count. Provide your own accessible label and interaction. |