Skip to main content
Version: v5


The UserAvatar component can be used to display a user avatar. If the user has a defined image, the UserAvatar will display it, otherwise it'll use the user's initials to display a text with a gradient background. And if the user is online and the user presence is enabled for the app, we'll display the online indicator.

Let's see how to use it in your code.


To use the component, simply pass the User object to the UserAvatar, like so:

user = user,
// Show online indicator
showOnlineIndicator = true,
// Reasonable avatar size
modifier = Modifier.size(36.dp)

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

The UserAvatar Component

Handling Actions

The UserAvatar component exposes only one action to handle click events:

fun UserAvatar(
..., // State
onClick: (() -> Unit)? = null,

By default, the UserAvatar component doesn't react to user clicks, but if you want to handle click events, you can do the following:

..., // State
) {
// Handle avatar clicks here


In terms of UI customization, the UserAvatar exposes the following properties:

fun UserAvatar(
user: User,
modifier: Modifier = Modifier,
shape: Shape = ChatTheme.shapes.avatar,
contentDescription: String? = null,
showOnlineIndicator: Boolean = true,
onlineIndicatorAlignment: OnlineIndicatorAlignment = OnlineIndicatorAlignment.TopEnd,
onlineIndicator: @Composable BoxScope.() -> Unit = {
OnlineIndicator(modifier = Modifier.align(onlineIndicatorAlignment.alignment))
... // Action handlers
  • user: The user whose avatar we want to show.
  • modifier: Modifier for the root component. Useful for things like the component size, padding, background and similar.
  • shape: The shape of the avatar.
  • contentDescription: The content description of the avatar.
  • showOnlineIndicator: If we show online indicator or not.
  • onlineIndicatorAlignment: The alignment of online indicator.
  • onlineIndicator: Custom composable that allows replacing the default online indicator.

Here's an example of customizing the UI of the user avatar:

modifier = Modifier.size(48.dp),
user = user,
onlineIndicator = {
modifier = Modifier
.background(Color.Blue, CircleShape)

The snippet above will produce an avatar with a blue online indicator:

The UserAvatar Component

Did you find this page helpful?