by @alexstyl
✉️ Leave your feedback

← Back to Material 3 Compose

BadgedBox

Component
in
Material 3
. Since 1.0.0

Overview

Examples

Community Notes

@Composable
fun NavigationBarItemWithBadge() {
    NavigationBar {
        NavigationBarItem(
            icon = {
                BadgedBox(
                    badge = {
                        Badge {
                            val badgeNumber = "8"
                            Text(
                                badgeNumber,
                                modifier = Modifier.semantics {
                                    contentDescription = "$badgeNumber new notifications"
                                }
                            )
                        }
                    }) {
                    Icon(
                        Icons.Filled.Star,
                        contentDescription = "Favorite"
                    )
                }
            },
            selected = false,
            onClick = {}
        )
    }
}
Previous ComponentBadge
Next ComponentBottomAppBar