Components · Avatar
Avatar
Displays a user's profile picture with initials fallback.
import { Avatar } from '@nexub/react';Playground
Props
<Avatar name="Alex Johnson" />Examples
Default
Sizes
With image
With badge
Agent avatar
AgentAvatar (12.2, beta) is for AI agents, so an agent never looks like a colleague: a rounded-square app tile, like the `@nexub/brand` tiles, with a sparkle in the bottom inline-end corner. Same sizes as Avatar. Screen readers hear "Payhub agent, AI agent".
States
defaultsize="sm"size="md"size="xs"size="lg"size="xl"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | — | URL of the profile image. |
| name | string | — | Full name used to generate initials when no image is provided. |
| size | 'sm' | 'md' | 'xs' | 'lg' | 'xl' | 'md' | Controls avatar dimensions. |
| badge | boolean | — | Shows a status badge on the avatar. |
| badgeColor | string | — | Colour of the status badge. |
| fallback | React.ReactNode | — | Custom fallback rendered when the image fails to load and no name is provided. |
| AgentAvatar icon | React.ReactNode | — | AgentAvatar (12.2, beta): the app glyph inside the tile, e.g. an @nexub/icons icon. Default: a bot. |
| AgentAvatar src | string | — | AgentAvatar: an image for the tile instead of icon (e.g. an @nexub/brand app tile). Falls back to icon if it fails. |
| AgentAvatar name | string | — | AgentAvatar: who the agent is ("Payhub agent"). Read as "Payhub agent, AI agent" (messages.aiAgent). |
| AgentAvatar size | 'sm' | 'md' | 'xs' | 'lg' | 'xl' | 'md' | AgentAvatar: the same size scale as Avatar. |
| AgentAvatar category | 'accent' | 'blue' | 'amber' | 'emerald' | 'pink' | 'violet' | 'cyan' | 'red' | 'lime' | — | AgentAvatar: a category colour for the tile. Default: the brand tile look, a primary glyph on a surface tile. |
| category | 'accent' | 'auto' | 'blue' | 'amber' | 'emerald' | 'pink' | 'violet' | 'cyan' | 'red' | 'lime' | — | 10.3: colour of the initials fallback. 'auto' picks a stable colour from name, so a list of people is easier to scan. Images are not affected. |
| status | 'online' | 'away' | 'busy' | 'offline' | — | Presence dot, added to the accessible name ("Ada Lovelace, Away"). Replaces badge when both are set. |
Design tokens
Avatar reads these component tokens. Each one is unset by default and falls back to the semantic role it aliases, so nothing changes until you set it. Set one on any element to restyle every Avatar below it, and leave the roles other components share alone. See the three token tiers.
| Token | Aliases | Notes |
|---|---|---|
| --avatar-bg | --color-surface-container-high | — |
| --avatar-fg | --color-on-surface-muted | — |
| --avatar-radius | 9999px | A circle. |
/* One area of your app */
.checkout {
--avatar-bg: var(--color-secondary);
}Accessibility
ARIA roles
Screen reader
Avatar reads its `name`, plus the `status` ("Ada Lovelace, Away"). Without a name it is decorative and hidden.
AgentAvatar is always `role="img"` and its name says it is an AI agent ("Payhub agent, AI agent", from `messages.aiAgent`). The glyph and the sparkle are hidden.
On iOS & Android: Avatar
import { Avatar } from '@nexub/react-native';
<Avatar src={user.photo} name={user.name} size="lg" status="online" />Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
Avatar props
| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | — | Image URL. Falls back to initials when missing or broken. |
| name | string | — | Person or org name: initials and the accessible name. |
| size | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' | — |
| badge | boolean | — | Online/status dot. |
| badgeColor | string | the success colour | Colour of the badge dot, any colour string. status wins when both are set. |
| fallback | React.ReactNode | — | Shown when there is no image and no name to take initials from, e.g. an icon. |
| status | 'online' | 'away' | 'busy' | 'offline' | — | Presence dot; its name is added to the accessible label ("Ada Lovelace, Away"). |
| category | CategoryColor | 'auto' | — | Colour of the initials fallback. 'auto' picks a stable colour from name,
the same one the web Avatar picks. Without it the avatar is neutral. |