Stylish Avatar
A circular avatar that shows a person's initials, an arbitrary image, or caller-supplied content.
When neither avatarImage nor content is provided, initials are rendered in MaterialTheme.typography.titleMedium, truncated to at most three characters. When avatarImage is provided it is clipped to the circle and fills the avatar. content takes precedence over avatarImage.
Accessibility: when initials is non-blank and no custom avatarImage or content is supplied, the initials are exposed as the avatar's androidx.compose.ui.semantics.contentDescription. For image avatars, set an appropriate description inside avatarImage (e.g. via Modifier.semantics) since the library cannot infer it.
The root carries the default test tag stylish_avatar for UI tests; callers can override it by passing their own Modifier.testTag(...) in modifier.
Parameters
Short text shown in the avatar, typically a person's initials (max 3 characters are displayed). Ignored when avatarImage or content is provided.
Modifier applied to the avatar surface. The size is enforced via size, overriding any incoming size modifier.
Diameter of the avatar. Defaults to 40.dp.
Background color of the avatar. Defaults to MaterialTheme.colorScheme.primaryContainer.
Default content color (text/icon) inside the avatar. Defaults to MaterialTheme.colorScheme.onPrimaryContainer.
Optional image content, clipped to the circle and scaled to fill the avatar. Ignored when content is provided.
Optional fully custom content, drawn centered inside the circle and taking precedence over avatarImage and initials.