# Avatar

An image element with a fallback for representing the user.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).





<ComponentPreview name="avatar-demo">
  <AvatarDemo />
</ComponentPreview>

## Installation [#installation]

<Tabs defaultValue="cli">
  <TabsList>
    <TabsTrigger value="cli">
      CLI
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add https://shadcn-cssinjs.com/r/avatar.json
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      pnpm add @base-ui/react @stylexjs/stylex
      ```

      <Step>
        Make sure [StyleX is configured](/docs/installation) and the design tokens are
        installed.
      </Step>

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource name="avatar" title="avatar.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</Tabs>

## Usage [#usage]

```tsx
import {
  Avatar,
  AvatarFallback,
  AvatarImage,
} from "@/components/ui/avatar/avatar";
```

```tsx
<Avatar>
  <AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
  <AvatarFallback>CN</AvatarFallback>
</Avatar>
```

## Composition [#composition]

Use the following composition to build a `Avatar`:

```txt
Avatar
├── AvatarImage
└── AvatarFallback
```

## Examples [#examples]



### Basic [#basic]

<ComponentPreview name="avatar-demo">
  <AvatarDemo />
</ComponentPreview>

### Badge [#badge]

Use `AvatarBadge` to display a status indicator.

<ComponentPreview name="avatar-badge">
  <AvatarWithBadge />
</ComponentPreview>

### Badge with Icon [#badge-with-icon]

<ComponentPreview name="avatar-badge-icon">
  <AvatarBadgeIcon />
</ComponentPreview>

### Avatar Group [#avatar-group]

Use `AvatarGroup` to display overlapping avatars.

<ComponentPreview name="avatar-group">
  <AvatarGroupExample />
</ComponentPreview>

### Avatar Group Count [#avatar-group-count]

Use `AvatarGroupCount` to display a count of additional members.

<ComponentPreview name="avatar-group-count">
  <AvatarGroupCountExample />
</ComponentPreview>

### Avatar Group with Icon [#avatar-group-with-icon]

<ComponentPreview name="avatar-group-count-icon">
  <AvatarGroupCountIcon />
</ComponentPreview>

### Sizes [#sizes]

Use the `size` prop to change the avatar size.

<ComponentPreview name="avatar-size">
  <AvatarSizeExample />
</ComponentPreview>

### Dropdown [#dropdown]

<ComponentPreview name="avatar-dropdown">
  <AvatarDropdown />
</ComponentPreview>



## RTL [#rtl]

To enable right-to-left support, see the [RTL guide](/docs/rtl).

<ComponentPreview name="avatar-rtl" direction="rtl">
  <AvatarRtl />
</ComponentPreview>

## API Reference [#api-reference]

See the [Base UI](https://base-ui.com/react/components/avatar#api-reference) documentation for the full API.
