# Avatar (/docs/native/components/avatar)

<Preview id="avatar/group" title={null} />

## Installation [#installation]

<ComponentInstall name="avatar" />

## Usage [#usage]

```tsx title="app/index.tsx"
import { Avatar } from "@/components/ui/avatar";
import { View } from "react-native";

export default function Example() {
  return (
    <View className="flex-1 items-center justify-center p-4">
      <Avatar name="Aria Whitlock" source={{ uri: "https://i.pravatar.cc/160?img=16" }} />
    </View>
  );
}
```

## Image and fallbacks [#image-and-fallbacks]

The initials show while the image loads, and in its place if it fails, so a dead URL never leaves an empty circle.

<Preview id="avatar/fallbacks" />

```tsx
<Avatar name="Aria Whitlock" source={{ uri: user.avatarUrl }} />
<Avatar name="Rawiri Kemp" />
<Avatar fallback="HQ" name="Harbour Studio" />
<Avatar />
```

## Sizes [#sizes]

A size is a fixed edge — 32, 40, 48, 64 and 96 points.

<Preview id="avatar/sizes" />

```tsx
<Avatar name="Priya Natarajan" size="sm" />
<Avatar name="Tomasi Fifita" size="md" />
<Avatar name="Kenji Moriyama" size="lg" />
<Avatar name="Lena Varga" size="xl" />
```

## Variants and colours [#variants-and-colours]

`variant` and `color` paint the fallback, on the six colours `Badge` takes.

<Preview id="avatar/variants-and-colours" />

```tsx
<Avatar name="Priya Natarajan" variant="soft" color="primary" />
<Avatar name="Saskia Lund" variant="solid" color="success" />
```

## Presence [#presence]

An empty `Avatar.Badge` is a presence dot; say the status in the avatar's own label.

<Preview id="avatar/presence" />

```tsx
<Avatar accessibilityLabel="Aria Whitlock, online" name="Aria Whitlock" source={photo}>
  <Avatar.Badge color="success" placement="bottom-right" />
</Avatar>
```

## Unread count [#unread-count]

Given children, `Avatar.Badge` only pins them to the corner.

<Preview id="avatar/unread-count" />

```tsx
import { Badge } from "@/components/ui/badge";

<Avatar name="Rawiri Kemp" source={photo}>
  <Avatar.Badge>
    <Badge color="destructive" size="sm">3</Badge>
  </Avatar.Badge>
</Avatar>;
```

## Pressable avatars [#pressable-avatars]

With no `onPress` and no `onLongPress` the root is a plain `View`; supply either and it becomes a `Pressable`.

```tsx
<Avatar name="Rawiri Kemp" onPress={openProfile} />
```

## Group [#group]

`max` caps the faces, not the row, and `total` counts people who were never passed as children.

```tsx
<Avatar.Group max={3} total={40}>
  <Avatar name="Aria Whitlock" source={aria} />
  <Avatar name="Rawiri Kemp" source={rawiri} />
  <Avatar name="Kenji Moriyama" />
</Avatar.Group>
```

## Overlap [#overlap]

`overlap` defaults to a third of the edge; `0` closes the stack into a plain row.

```tsx
<Avatar.Group overlap={0} size="sm">…</Avatar.Group>
```

## API Reference [#api-reference]

### AvatarProps [#avatarprops]

A pressable avatar is a `Pressable`, so `feedback`, `haptic`, `onPress` and the rest are inherited rather than
restated — see [Pressable](/docs/native/components/pressable). `asChild`, `busy` and `disabled` are withheld: use
`isDisabled`.

<TypeTable
  type={{
    source: {
      type: "ImageSourcePropType",
      description: "The picture. The fallback shows while it loads and if it fails; a new URI or header set retries.",
    },
    name: { type: "string", description: "Read by screen readers; its initials are the default fallback." },
    fallback: { type: "string", description: "Drawn instead of the initials of `name`." },
    variant: { type: '"soft" | "solid"', default: '"soft"' },
    color: {
      type: '"default" | "primary" | "success" | "warning" | "destructive" | "info"',
      default: '"default"',
    },
    size: { type: '"sm" | "md" | "lg" | "xl" | "2xl"', default: '"md", or the group\'s size' },
    isDisabled: { type: "boolean", description: "Fades the avatar and blocks its press." },
    imageProps: {
      type: 'Omit<ImageProps, "source">',
      description: "Passed to the `Image`. `onError` fires after the fallback has taken over.",
    },
    className: { type: "string" },
    children: { type: "ReactNode", description: "Overlays — an `Avatar.Badge`." },
  }}
/>

### Avatar.Badge [#avatarbadge]

An overlay pinned to a corner, outside the clipped circle. Empty, it draws a presence dot. Extends `ViewProps`.

<TypeTable
  type={{
    placement: { type: '"top-right" | "bottom-right"', default: '"top-right"' },
    color: {
      type: '"default" | "primary" | "success" | "warning" | "destructive" | "info"',
      default: '"success"',
      description: "The presence dot's colour. Ignored when there are children.",
    },
    className: { type: "string" },
    children: { type: "ReactNode" },
  }}
/>

### Avatar.Group [#avatargroup]

A row of overlapping avatars, first on top, with the people who did not fit counted at the end. Extends `ViewProps`.

<TypeTable
  type={{
    size: { type: '"sm" | "md" | "lg" | "xl" | "2xl"', default: '"md"', description: "A child's own `size` still wins." },
    max: { type: "number", description: "How many faces to show. The rest are counted into a trailing `+N`." },
    total: { type: "number", description: "How many people there are, when the children are only the first few." },
    overlap: { type: "number", description: "Points each face slides under the one before. Defaults to a third of the size." },
    onOverflowPress: { type: "() => void", description: "Makes the `+N` tile a button." },
    className: { type: "string" },
    children: { type: "ReactNode" },
  }}
/>
