User Avatar
fun UserAvatar(url: String?, name: String?, size: Dp = 24.dp, modifier: Modifier = Modifier, onClick: () -> Unit? = null)(source)
Renders a circular user avatar with in-memory caching and fallback to author initials.
Asynchronously downloads the image from url using an in-memory bitmap cache (avatarCache). If url is null, blank, or fails to load, generates a deterministic background color from the user's name hash and renders their capitalized initial (or a generic silhouette if no name is provided).
Example Usage
UserAvatar(
url = "https://cdn.cupthread.com/avatars/user_123.png",
name = "Alex Johnson",
size = 32.dp,
onClick = { /* open user profile */}
)Content copied to clipboard
Parameters
url
Remote image URL for the avatar picture, or null.
name
Display name of the user used to generate initials and deterministic background color.
size
Target diameter of the circular avatar; defaults to 24.dp.
modifier
Optional Modifier applied to the avatar container.
on Click
Optional callback invoked when the avatar is clicked.