# Avatar · JGuang UI

> An image element with a fallback for representing the user.

- Page: https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar
- Based on: shadcn/ui documentation (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c

> Example `avatar-demo`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


## Installation


  

**Command**


  

**Manual**


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Install the following dependencies:


```bash
npm install @base-ui/react
```


### Copy and paste the following code into your project.


[View complete source: components/ui/avatar.tsx](/r/jguang-ui/base/avatar.json)


### Update the import paths to match your project setup.


## Usage

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

```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```

## Composition

Use the following composition to build an `Avatar`:

```text
Avatar
├── AvatarImage
├── AvatarFallback
└── AvatarBadge
```

Use the following composition to build an `AvatarGroup`:

```text
AvatarGroup
├── Avatar
│   ├── AvatarImage
│   ├── AvatarFallback
│   └── AvatarBadge
├── Avatar
│   ├── AvatarImage
│   ├── AvatarFallback
│   └── AvatarBadge
└── AvatarGroupCount
```

## Basic

A basic avatar component with an image and a fallback.


> Example `avatar-basic`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


## Badge

Use the `AvatarBadge` component to add a badge to the avatar. The badge is positioned at the bottom right of the avatar.


> Example `avatar-badge`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


Use the `className` prop to add custom styles to the badge such as custom colors, sizes, etc.

```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```

## Badge with Icon

You can also use an icon inside `<AvatarBadge>`.


> Example `avatar-badge-icon`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


## Avatar Group

Use the `AvatarGroup` component to add a group of avatars.


> Example `avatar-group`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


## Avatar Group Count

Use `<AvatarGroupCount>` to add a count to the group.


> Example `avatar-group-count`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


## Avatar Group with Icon

You can also use an icon inside `<AvatarGroupCount>`.


> Example `avatar-group-count-icon`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


## Sizes

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


> Example `avatar-size`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


## Dropdown

You can use the `Avatar` component as a trigger for a dropdown menu.


> Example `avatar-dropdown`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> Example `avatar-rtl`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/base/avatar


## API Reference

### Avatar

The `Avatar` component is the root component that wraps the avatar image and fallback.

| Prop        | Type                        | Default     |
| ----------- | --------------------------- | ----------- |
| `size`      | `"default" \| "sm" \| "lg"` | `"default"` |
| `className` | `string`                    | -           |

### AvatarImage

The `AvatarImage` component displays the avatar image. It accepts all Base UI Avatar Image props.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `src`       | `string` | -       |
| `alt`       | `string` | -       |
| `className` | `string` | -       |

### AvatarFallback

The `AvatarFallback` component displays a fallback when the image fails to load. It accepts all Base UI Avatar Fallback props.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` | -       |

### AvatarBadge

The `AvatarBadge` component displays a badge indicator on the avatar, typically positioned at the bottom right.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` | -       |

### AvatarGroup

The `AvatarGroup` component displays a group of avatars with overlapping styling.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` | -       |

### AvatarGroupCount

The `AvatarGroupCount` component displays a count indicator in an avatar group, typically showing the number of additional avatars.

| Prop        | Type     | Default |
| ----------- | -------- | ------- |
| `className` | `string` | -       |

For more information about Base UI Avatar props, see the [Base UI documentation](https://base-ui.com/react/components/avatar#api-reference).

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
