# UserAvatar

The [`UserAvatar`](https://github.com/GetStream/stream-chat-android/blob/main/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/UserAvatar.kt) component displays a user avatar. Based on the user state, it shows either the user's profile image or their initials with a gradient background. If the user is online, an online indicator is displayed.

## Usage

To use the component, pass the `User` object to the `UserAvatar`:

```kotlin
UserAvatar(
    user = user,
    showIndicator = true,
    modifier = Modifier.size(36.dp)
)
```

Depending on the state within the `User` object, the snippet above will produce the following UI:

| ![Default UserAvatar Component](https://getstream.io/docs-assets/images/859be6195fbd.png) |
| -------------------------------------------------------------------------------------------------------------- |

## Customization

The `UserAvatar` exposes the following properties for customization:

```kotlin
@Composable
fun UserAvatar(
    user: User,
    modifier: Modifier = Modifier,
    showIndicator: Boolean = false,
    showBorder: Boolean = false,
)
```

- `user`: The user whose avatar to display.
- `modifier`: Modifier for the root component. Useful for the component size, padding, background and similar.
- `showIndicator`: Whether to display the online status indicator. Defaults to `false`.
- `showBorder`: Whether to show a border around the avatar. Defaults to `false`.

The avatar's appearance (shape, placeholder colors, initials style) is managed internally by the component and adapts to the current theme. When no image is available, the avatar displays the user's initials with a deterministic background.

>
> **Tip:** For deeper customization of avatar rendering, you can override the `ChatComponentFactory#UserAvatar` method. See the [Component Factory](https://getstream.io/chat/docs/sdk/android/compose/general-customization/component-factory/) page for details.
>

---

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/sdk/android/compose/utility-components/user-avatar/](https://getstream.io/chat/docs/sdk/android/compose/utility-components/user-avatar/).