androidx.compose.material3
NavigationBar
Composable function
A navigation bar switches between the main destinations of an app. Use it on phones, with three to five items.
On wider screens, use a NavigationRail instead.
Put it in the bottomBar slot of a Scaffold. Inside, add one NavigationBarItem per destination.
The bar does not know which item is selected. You keep the selected index in a variable.

var selected by remember { mutableIntStateOf(0) }
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 = null) },
label = { Text(label) },
)
}
}
Parameters
@Composable
fun NavigationBar(
modifier: Modifier = Modifier,
containerColor: Color = NavigationBarDefaults.containerColor,
contentColor: Color = MaterialTheme.colorScheme.contentColorFor(containerColor),
tonalElevation: Dp = NavigationBarDefaults.Elevation,
windowInsets: WindowInsets = NavigationBarDefaults.windowInsets,
content: @Composable RowScope.() -> Unit,
)
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
containerColor: ColorOptional
containerColor: ColorOptionalDefault: NavigationBarDefaults.containerColor
The background color of the bar.
contentColor: ColorOptional
contentColor: ColorOptionalDefault: MaterialTheme.colorScheme.contentColorFor(containerColor)
The default color for content inside the bar.
tonalElevation: DpOptional
tonalElevation: DpOptionalDefault: NavigationBarDefaults.Elevation
Tints the background a little toward the primary color, to set the bar apart from the page.
windowInsets: WindowInsetsOptional
windowInsets: WindowInsetsOptionalDefault: NavigationBarDefaults.windowInsets
Space kept free for system bars, like the gesture bar on phones. The default is usually right.
content: @Composable RowScope.() -> UnitRequired
content: @Composable RowScope.() -> UnitRequiredThe items. Add one NavigationBarItem for each destination. They share the width equally.
Parts
NavigationBarNavigationBarItem
See also
NavigationBarDefaults: default values and helper functions forNavigationBar.