androidx.compose.material3
NavigationBarItem
Composable function
A part of NavigationBar. See that page for an overview and examples.
Parameters
@Composable
fun RowScope.NavigationBarItem(
selected: Boolean,
onClick: () -> Unit,
icon: @Composable () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
label: @Composable (() -> Unit)? = null,
alwaysShowLabel: Boolean = true,
colors: NavigationBarItemColors = NavigationBarItemDefaults.colors(),
interactionSource: MutableInteractionSource? = null,
)
selected: BooleanRequired
selected: BooleanRequiredWhether this item is the current destination. Usually index == selectedIndex.
onClick: () -> UnitRequired
onClick: () -> UnitRequiredCalled when the item is clicked. Set your selected index and navigate here.
icon: @Composable () -> UnitRequired
icon: @Composable () -> UnitRequiredThe icon of the item. Wrap it in a BadgedBox to show a count.

NavigationBar(Modifier.width(360.dp)) {
NavigationBarItem(selected = true, onClick = {}, icon = { Icon(Icons.Filled.Home, null) }, label = { Text("Home") })
NavigationBarItem(
selected = false,
onClick = {},
icon = {
BadgedBox(badge = { Badge { Text("3") } }) { Icon(Icons.Filled.Favorite, null) }
},
label = { Text("Favorites") },
)
}
enabled: BooleanOptional
enabled: BooleanOptionalDefault: true
Set to false to make the item gray and not clickable.
label: @Composable (() -> Unit)?Optional
label: @Composable (() -> Unit)?OptionalDefault: null
The name of the destination. Keep it to one short word.
alwaysShowLabel: BooleanOptional
alwaysShowLabel: BooleanOptionalDefault: true
Set to false to show the label only on the selected item.

var selected by remember { mutableIntStateOf(1) }
val items = listOf("Home" to Icons.Filled.Home, "Favorites" to Icons.Filled.Favorite, "Settings" to Icons.Filled.Settings)
NavigationBar(Modifier.width(360.dp)) {
items.forEachIndexed { index, (label, icon) ->
NavigationBarItem(
selected = selected == index,
onClick = { selected = index },
icon = { Icon(icon, contentDescription = label) },
label = { Text(label) },
alwaysShowLabel = false,
)
}
}
colors: NavigationBarItemColorsOptional
colors: NavigationBarItemColorsOptionalDefault: NavigationBarItemDefaults.colors()
Sets icon, label and indicator colors for selected, unselected and disabled items.
Make one with NavigationBarItemDefaults.colors.
interactionSource: MutableInteractionSource?Optional
interactionSource: MutableInteractionSource?OptionalDefault: null
Lets you observe or control press, hover and focus states. Leave it null unless your code must react to them. See InteractionSource.
Same as in NavigationBar: modifier.
Parts
NavigationBarNavigationBarItem
See also
NavigationBarDefaults: default values and helper functions forNavigationBarItem.