Avatar
Avatars display a user's profile image or initials as fallback.
Examples
Initials
Variants
With tooltip
With image
Sizes
Stacked group
Stacked with custom colors
Stacked with tooltips
Overview
Avatar displays a user's profile image with automatic fallback to initials or icons when no image is available. Three composable parts: Avatar (root), AvatarImage, and AvatarFallback.
import { Avatar, AvatarImage, AvatarFallback } from "@rogo-technologies/ui/avatar";
<Avatar>
<AvatarImage src="/avatar.jpg" alt="John Doe" />
<AvatarFallback>J</AvatarFallback>
</Avatar>;Always include an AvatarFallback alongside AvatarImage to handle loading states and broken images. AvatarFallback truncates string children to a single character — pass the first initial only.
Usage
Variants
Use variant="primary" (the default) for branded fallbacks — the active user, Rogo-owned entities, anywhere you want the avatar to feel "ours". Use variant="secondary" for neutral cases where colour would compete with surrounding UI: overflow chips, low-emphasis lists, or contexts where the avatar is decorative rather than identifying.
For team / category colours, reach for the decorative variants — green, blue, olive, crimson. They share a text-neutral-300 foreground so initials stay legible across all four hues.
<Avatar>
<AvatarFallback>J</AvatarFallback>
</Avatar>
<Avatar variant="secondary">
<AvatarFallback>3</AvatarFallback>
</Avatar>
<Avatar variant="green">
<AvatarFallback>A</AvatarFallback>
</Avatar>Sizes
| Size | Dimensions | Use case |
|---|---|---|
xs | 12px | Compact lists, inline mentions |
sm | 16px | Dense layouts, small indicators |
md | 20px | Default — lists, cards, comments |
lg | 24px | Profile sections, headers |
xl | 32px | Profile pages, hero sections |
2xl | 40px | Large profile displays, account pages |
<Avatar size="lg">
<AvatarFallback>J</AvatarFallback>
</Avatar>Stacked groups
Use AvatarStack — it handles overlap, the per-position mask cutouts, and the hover interaction (lift to z-20, drop self-mask, push the next sibling's left-cutout in) automatically.
import {
Avatar,
AvatarFallback,
AvatarOverflow,
AvatarStack,
} from "@rogo-technologies/ui/avatar";
<AvatarStack size="lg">
<Avatar tooltip="Alice Brown" variant="green">
<AvatarFallback>A</AvatarFallback>
</Avatar>
<Avatar tooltip="Carla Diaz" variant="blue">
<AvatarFallback>C</AvatarFallback>
</Avatar>
<AvatarOverflow tooltip="3 more people">+3</AvatarOverflow>
</AvatarStack>;AvatarStack enforces a single size for all children, and the last entry is treated specially — it only gains a left-cutout when its predecessor is hovered, never a right-cutout, since it has no neighbour on the right.
Overflow chip
For "+N more" counters or any non-initial string that needs to sit in a stack, use AvatarOverflow. It shares Avatar's circular geometry and size scale so masks line up, but renders in font-sans on bg-tertiary / text-tertiary to read as a neutral count rather than a person. Multi-character strings are not truncated.
<AvatarStack size="lg">
<Avatar variant="green">
<AvatarFallback>A</AvatarFallback>
</Avatar>
<AvatarOverflow tooltip="3 more people">+3</AvatarOverflow>
</AvatarStack>Generating initials
function getInitial(name: string): string {
return name.trim().charAt(0).toUpperCase();
}
<Avatar>
<AvatarImage src={user.avatar} alt={user.name} />
<AvatarFallback>{getInitial(user.name)}</AvatarFallback>
</Avatar>;Tooltip
Pass a tooltip prop (string or React node) and the avatar wires up a default Tooltip out of the box — no need to compose Tooltip / TooltipTrigger / TooltipContent by hand. Useful in stacks where each face needs its own name on hover.
<Avatar tooltip="Jane Doe">
<AvatarFallback>J</AvatarFallback>
</Avatar>
<Avatar tooltip={<span>Alex Brown<br/>alex@example.com</span>}>
<AvatarFallback>A</AvatarFallback>
</Avatar>For richer behaviour (custom side, delay, controlled open state), compose Tooltip manually instead of using this prop.
Custom render
Render the avatar as a link or other element with render.
import Link from "next/link";
<Avatar render={<Link href="/profile" />}>
<AvatarImage src="/avatar.jpg" alt="Profile" />
<AvatarFallback>J</AvatarFallback>
</Avatar>;Accessibility
- Always provide meaningful
alttext forAvatarImage - When using icons as fallback, give them an
aria-label - Avatar groups should use
aria-labelto describe the group
API
Avatar
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "md" | Size of the avatar. |
variant | "primary" | "secondary" | "green" | "blue" | "olive" | "crimson" | "primary" | Fallback colour. primary is brand; secondary is neutral; decorative variants use text-neutral-300 on the matching decorative background. |
tooltip | ReactNode | — | If set, wraps the avatar in a Tooltip with this content. String or node. |
render | ReactElement | ((props) => ReactElement) | — | Render as a custom element. |
className | string | — | Additional CSS classes. |
AvatarImage
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | — | Source URL of the image. |
alt | string | — | Alt text for accessibility. |
render | ReactElement | ((props) => ReactElement) | — | Render as a custom element (e.g., Next.js Image). |
className | string | — | Additional CSS classes. |
AvatarStack
| Prop | Type | Default | Description |
|---|---|---|---|
size | "md" | "lg" | "lg" | Avatar size for all children. Overrides each child's size prop. |
className | string | — | Additional classes on the layout container. |
children | ReactNode | — | <Avatar> children. Position-aware: first / middle / last get distinct masks. |
AvatarFallback
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Fallback content (initials, icon, etc.). |
render | ReactElement | ((props) => ReactElement) | — | Render as a custom element. |
className | string | — | Additional CSS classes. |
AvatarOverflow
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "md" | Size of the chip. Mirrors Avatar so masks align inside AvatarStack. |
tooltip | ReactNode | — | If set, wraps the chip in a Tooltip with this content. |
children | ReactNode | — | Chip content. Strings are rendered as-is — no truncation. |
className | string | — | Additional CSS classes. |
Guidelines
Do
- Always include
AvatarFallbackwhen usingAvatarImage - Use the first initial of the name for fallbacks — the component truncates strings to one character
- Use consistent sizes within the same context
- Use a
mask-imagecutout (not a ring) when stacking avatars so the separation is surface-agnostic - Use
size="xl"orsize="lg"for profile headers and hero sections - Reach for decorative variants (
green/blue/olive/crimson) for team or category colour instead of overridingclassNamewith raw Tailwind colours
Don't
- Don't pass multi-character strings expecting them to render —
AvatarFallbackslices to one character - Don't use
size="xs"for standalone avatars — it's too small to be meaningful - Don't forget alt text for images
- Don't mix different sizes in the same avatar group
- Don't rely solely on the avatar to convey identity — pair with a name when possible