# Avatar

An image, fallback, status, and tooltip representation for a person or entity.

An image, fallback, status, and tooltip representation for a person or entity.

<p className="zenos-base-ui-source">
  Backed by <a href="https://base-ui.com/react/components/avatar">Base UI Avatar</a> for upstream
  behavior and configuration. Zenos owns the public API, styling, and composition shown on this
  page.
</p>

```tsx
import { Avatar, Stack } from "@zentara-co/zenos-ui";

function AvatarPreviewExample() {
  return (
    <Stack direction="row" align="center" gap="4" wrap="wrap" className="justify-center">
      <Avatar name="Alex Daniels" size="lg" />
      <Avatar name="Mina Cho" size="lg" shape="rounded" />
      <Avatar
        name="Sam Ortiz"
        size="lg"
        status={<Avatar.StatusDot variant="success" label="Online" />}
      />
    </Stack>
  );
}
```

## Import

```tsx
import { Avatar } from "@zentara-co/zenos-ui";
```

## Sizes

Use a named size for the shared scale or one of the supported numeric pixel sizes for a specific context.

```tsx
import { Avatar, Stack } from "@zentara-co/zenos-ui";

function AvatarSizesExample() {
  return (
    <Stack direction="row" align="center" gap="4" wrap="wrap">
      {(["xsm", "sm", "md", "lg", "xl"] as const).map((size) => (
        <Avatar key={size} name={size} size={size} tooltip={`Size: ${size}`} />
      ))}
      <Avatar name="72" size={72} tooltip="Numeric size: 72px" />
    </Stack>
  );
}
```

## Shapes

```tsx
import { Avatar, Stack } from "@zentara-co/zenos-ui";

function AvatarShapesExample() {
  return (
    <Stack direction="row" align="center" gap="4" wrap="wrap">
      {(["circle", "rounded", "square"] as const).map((shape) => (
        <Avatar key={shape} name={shape} shape={shape} size="lg" />
      ))}
    </Stack>
  );
}
```

## Status

Status dots contribute their label to the Avatar's accessible name. Do not rely on the dot color alone.

```tsx
import { Avatar, Stack } from "@zentara-co/zenos-ui";

function AvatarStatusesExample() {
  return (
    <Stack direction="row" align="center" gap="4" wrap="wrap">
      {(["success", "neutral", "error"] as const).map((variant) => (
        <Avatar
          key={variant}
          name={variant}
          size="lg"
          status={<Avatar.StatusDot variant={variant} label={variant} />}
        />
      ))}
    </Stack>
  );
}
```

## Fallbacks and tooltips

`name` generates initials and is the default tooltip. A failed image falls back to initials, while an unnamed avatar uses the generic person icon.

```tsx
import { Avatar, Stack } from "@zentara-co/zenos-ui";

function AvatarFallbackExample() {
  return (
    <Stack direction="row" align="center" gap="4" wrap="wrap">
      <Avatar name="Alex Daniels" size="lg" tooltip="Alex Daniels · Product designer" />
      <Avatar name="Mina Cho" src="/missing-avatar.png" size="lg" />
      <Avatar aria-label="Anonymous user" size="lg" tooltip="Anonymous user" />
    </Stack>
  );
}
```

## Custom styling

Use `className` on `Avatar` to style its root and stable slots such as `avatar-fallback`. Status content remains independently customizable through `Avatar.StatusDot`. Keep `name`, `alt`, and the status `label` meaningful when changing the visual treatment.

```tsx
import { Avatar } from "@zentara-co/zenos-ui";

function AvatarCustomStylingExample() {
  return (
    <Avatar
      name="Maya Chen"
      size={96}
      shape="rounded"
      className="border-4 border-border-accent-purple-default bg-background-accent-purple-subtlest-default shadow-overlay [&_[data-slot=avatar-fallback]]:bg-background-accent-purple-subtlest-pressed [&_[data-slot=avatar-fallback]]:text-text-accent-purple-bolder"
      status={
        <Avatar.StatusDot
          label="Available"
          className="border-background-neutral-card bg-background-accent-purple-bolder-default text-text-contrary dark:border-background-neutral-card dark:bg-background-accent-purple-bolder-default dark:text-text-contrary"
        />
      }
    />
  );
}
```

## Anatomy

```text
Avatar
Avatar.Root
Avatar.Image
Avatar.Fallback
Avatar.StatusDot
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| src | string | — | Image URL. |
| alt | string | — | Image alternative text. |
| name | string | — | Display name used to generate initials and tooltip content. |
| Root.size | AvatarSize | md | Named or supported numeric size. |
| shape | circle \| rounded \| square | circle | Avatar geometry. |
| tooltip | boolean \| string | true | Uses the name or a custom string as tooltip content. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Avatar uses Base UI's image loading and fallback behavior. Provide `name` or `alt` for meaningful avatars, label status dots, and use `tooltip={false}` only when the surrounding interface already identifies the person.

Source: https://zenos-ui.pages.dev/components/avatar/