Badge

A small marker that shows a status or a count on top of another element.

When to use

A small badge is a dot that says something changed. A large badge carries a number or a short text. Attach badges to icons in navigation bars, rails and toolbars with BadgedBox.

Cap counts at 99 and show 99+ above that.

Playground

The interactive page has a playground with live property controls for this component and generated code.

Examples

Dot and count

BadgedBox(badge = { Badge() }) {
    Icon(Icons.Rounded.NotificationsActive, contentDescription = "Alerts")
}
BadgedBox(badge = { Badge { Text("3") } }) {
    Icon(Icons.Rounded.Email, contentDescription = "Inbox, 3 unread")
}
BadgedBox(badge = { Badge { Text("99+") } }) {
    Icon(Icons.Rounded.Notifications, contentDescription = "Notifications, more than 99")
}

Parameters

NameTypeDefaultDescription
badge@Composable BoxScope.() -> UnitThe Badge to show on the anchor.
content@Composable BoxScope.() -> UnitThe anchor, usually an Icon.
containerColorColorBadgeDefaults.containerColorBadge color, error by default.

Guidelines

Do:

Don't:

Accessibility

Related components