androidx.compose.material3
BadgedBox
Composable function
A badge shows a count or a dot on an icon, for example unread messages.
Put the icon in a BadgedBox, and the Badge in its badge slot. The box places the badge on the top end corner.

Row(horizontalArrangement = Arrangement.spacedBy(32.dp)) {
BadgedBox(badge = { Badge { Text("8") } }) {
Icon(Icons.Filled.Email, contentDescription = "8 new messages")
}
BadgedBox(badge = { Badge() }) {
Icon(Icons.Filled.Notifications, contentDescription = "New notifications")
}
}
A badge without content is a small dot. With a Text inside, it grows to fit. Keep the text short, like "999+".

Box(Modifier.padding(8.dp)) {
BadgedBox(badge = { Badge { Text("999+") } }) {
Icon(Icons.Filled.Email, contentDescription = "Many messages")
}
}
Parameters
@Composable
fun BadgedBox(
badge: @Composable BoxScope.() -> Unit,
modifier: Modifier = Modifier,
content: @Composable BoxScope.() -> Unit,
)
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
Parts
BadgedBoxBadge