androidx.compose.material3
NavigationRail
Composable function
A navigation rail switches between the main destinations of an app, like a NavigationBar, but sits at the side.
Use it on tablets and desktops. Put it next to your content in a Row.
Inside, add one NavigationRailItem per destination. 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)
NavigationRail(
modifier = Modifier.height(400.dp),
header = {
FloatingActionButton(onClick = {}) { Icon(Icons.Filled.Add, "Add") }
},
) {
items.forEachIndexed { index, (label, icon) ->
NavigationRailItem(
selected = selected == index,
onClick = { selected = index },
icon = { Icon(icon, contentDescription = null) },
label = { Text(label) },
)
}
}
Parameters
@Composable
fun NavigationRail(
modifier: Modifier = Modifier,
containerColor: Color = NavigationRailDefaults.ContainerColor,
contentColor: Color = contentColorFor(containerColor),
header: @Composable (ColumnScope.() -> Unit)? = null,
windowInsets: WindowInsets = NavigationRailDefaults.windowInsets,
content: @Composable ColumnScope.() -> Unit,
)
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
containerColor: ColorOptional
containerColor: ColorOptionalDefault: NavigationRailDefaults.ContainerColor
The background color of the rail.
contentColor: ColorOptional
contentColor: ColorOptionalDefault: contentColorFor(containerColor)
The default color for content inside the rail.
header: @Composable (ColumnScope.() -> Unit)?Optional
header: @Composable (ColumnScope.() -> Unit)?OptionalDefault: null
Something above the items, usually a FloatingActionButton or a menu button.
windowInsets: WindowInsetsOptional
windowInsets: WindowInsetsOptionalDefault: NavigationRailDefaults.windowInsets
Space kept free for system bars. The default is usually right.
content: @Composable ColumnScope.() -> UnitRequired
content: @Composable ColumnScope.() -> UnitRequiredThe items. Add one NavigationRailItem for each destination. Items are placed in a Column, top to bottom.
Parts
NavigationRailNavigationRailItem
See also
NavigationRailDefaults: default values and helper functions forNavigationRail.