Skip to main content

Avatar

Avatar is a visual identifier that represents a person or team, such as a profile owner or a project's collaborators.

Import

import { Avatar } from '@vortexlabs/vortex-native';
import type { AvatarProps } from '@vortexlabs/vortex-native';

Other links

import { Avatar } from "@vortexlabs/vortex-native";

<Avatar
  initials="AL"
  size="lg"
  tone="primary"
  variant="subtle"
  rounded={false}
/>

Features

  • Displays an image, initials, or an icon.
  • Shows initials or an icon while a photo loads and if it fails.
  • Supports six responsive sizes, two shapes, and seven color tones.
  • Pairs avatars with names and supporting text.
  • Displays status indicators and overlapping groups with an overflow count.

Content

Use a photo for a person, initials when you only have a name, or an icon for a team. Pass a URL or a bundled image such as require("./bonnie.jpg") to src.

import { Avatar, Stack } from "@vortexlabs/vortex-native";
import { Hexagon } from "@vortexlabs/vortex-icons";

const photo = "https://pbs.twimg.com/profile_images/1536360219147907073/RX64EVOE_400x400.jpg";

export const TeamAvatars = () => (
<Stack direction="row" gap={2} align="center" wrap>
  <Avatar src={photo} initials="BH" alt="Bonnie Hong" />
  <Avatar initials="AL" tone="primary" />
  <Avatar icon={Hexagon} alt="Vortex workspace" />
</Stack>
);

Image fallback

Pass initials or icon alongside src. The fallback stays visible until the photo loads and remains visible if the request fails. The example shows the initials for a photo that fails to load.

import { Avatar } from "@vortexlabs/vortex-native";

type Props = { photoUrl: string };

export const ProfilePhoto = (props: Props) => {
  const { photoUrl } = props;
  return <Avatar src={photoUrl} initials="BH" tone="secondary" alt="Bonnie Hong" />;
};

Sizes

Avatar ranges from 24 points at xs to 64 points at 2xl. The default size is lg.

<Stack direction="row" gap={2} align="center" wrap>
  <Avatar initials="AL" size="xs" />
  <Avatar initials="AL" size="sm" />
  <Avatar initials="AL" size="md" />
  <Avatar initials="AL" size="lg" />
  <Avatar initials="AL" size="xl" />
  <Avatar initials="AL" size="2xl" />
</Stack>

Responsive size

Pass a breakpoint object to use a compact avatar on small screens and a larger photo or monogram when the layout has more room.

<Avatar initials="AL" size={{ xs: "sm", md: "xl" }} />

Shape

Avatar renders a rounded square by default. Set rounded for a circle.

<Stack direction="row" gap={2} align="center" wrap>
  <Avatar initials="AL" tone="primary" />
  <Avatar initials="AL" tone="primary" rounded />
</Stack>

Variants

Use solid for a filled background or subtle for a tinted background. These styles apply to initials, icons, and photo fallbacks.

<Stack direction="row" gap={2} align="center" wrap>
  <Avatar initials="AL" tone="primary" variant="solid" />
  <Avatar initials="AL" tone="primary" variant="subtle" />
</Stack>

Tone

Choose a tone for the initials or icon. A loaded photo covers the background.

<Stack direction="row" gap={2} align="center" wrap>
  <Avatar initials="AL" tone="neutral" variant="subtle" />
  <Avatar initials="BH" tone="primary" variant="subtle" />
  <Avatar initials="US" tone="secondary" variant="subtle" />
  <Avatar initials="KT" tone="info" variant="subtle" />
  <Avatar initials="GH" tone="success" variant="subtle" />
  <Avatar initials="MK" tone="warning" variant="subtle" />
  <Avatar initials="JD" tone="critical" variant="subtle" />
</Stack>

Online and verified status

Use onlineIndicator for presence and verified for a verified photo. Include the status in alt so the name still communicates it at xs, where both indicators are hidden.

const photo = "https://pbs.twimg.com/profile_images/1536360219147907073/RX64EVOE_400x400.jpg";

<Stack direction="row" gap={2} align="center" wrap>
<Avatar initials="AL" onlineIndicator alt="Ada Lovelace, online" />
<Avatar src={photo} initials="BH" verified alt="Bonnie Hong, verified" />
</Stack>

Composition

Use Avatar.Item inside a profile or a group. The parent supplies its size.

Avatar.Root

Pair a photo with a visible name and supporting text. The default layout is a row. For a profile header, stack the parts vertically and center the text. Set the size on the root to scale the avatar and text together.

const photo = "https://pbs.twimg.com/profile_images/1536360219147907073/RX64EVOE_400x400.jpg";

<Avatar.Root size="md" direction="column">
<Avatar.Item src={photo} initials="BH" rounded />
<Avatar.Content align="center">
  <Avatar.Title>Bonnie Hong</Avatar.Title>
  <Avatar.HelperText>Product designer</Avatar.HelperText>
</Avatar.Content>
</Avatar.Root>

Avatar.Group

Give the list an accessible name and supply one Avatar.Item per person. The group accepts xs, sm, or md (default). Here, limit={3} shows three reviewers and a +2 count. Omit the limit to show everyone.

const photo = "https://pbs.twimg.com/profile_images/1536360219147907073/RX64EVOE_400x400.jpg";

<Avatar.Group ariaLabel="Reviewers" rounded size="sm" limit={3}>
<Avatar.Item src={photo} initials="BH" alt="Bonnie Hong" />
<Avatar.Item initials="AL" tone="primary" />
<Avatar.Item initials="GH" tone="secondary" />
<Avatar.Item initials="KT" />
<Avatar.Item initials="MK" />
</Avatar.Group>

Accessibility

Description
Provide alt for a standalone image or icon. Use an empty string when adjacent text already communicates the name and status.
Screen readers read plain initials directly. Add alt when an initials avatar shows an online indicator.
Inside Avatar.Root, the title and helper text can name the person and their status together. Omit the item’s alt when those labels provide both.
Inside Avatar.Group, label each photo, icon, or online item. The overflow item announces the count of additional people.