androidx.compose.material3
WideNavigationRailSince 1.9
Composable function
The wide navigation rail is the Expressive version of the NavigationRail. It can collapse to a narrow rail, or expand to a wider panel with labels next to icons, like a drawer.
The rail's state decides if it is expanded. Create it with rememberWideNavigationRailState(), and call expand(), collapse() or toggle() on it from a coroutine, for example from a menu button in the header.

var selected by remember { mutableIntStateOf(0) }
val state = rememberWideNavigationRailState(WideNavigationRailValue.Expanded)
val items = listOf("Home" to Icons.Filled.Home, "Favorites" to Icons.Filled.Favorite, "Settings" to Icons.Filled.Settings)
WideNavigationRail(state = state, modifier = Modifier.height(320.dp)) {
items.forEachIndexed { index, (label, icon) ->
WideNavigationRailItem(
railExpanded = state.targetValue == WideNavigationRailValue.Expanded,
selected = selected == index,
onClick = { selected = index },
icon = { Icon(icon, contentDescription = null) },
label = { Text(label) },
)
}
}
ModalWideNavigationRail opens over the content with a dim layer, like a modal drawer. Use it on smaller screens.
Parameters
@Composable
fun WideNavigationRail(
modifier: Modifier = Modifier,
state: WideNavigationRailState = rememberWideNavigationRailState(),
shape: Shape = WideNavigationRailDefaults.shape,
colors: WideNavigationRailColors = WideNavigationRailDefaults.colors(),
header: @Composable (() -> Unit)? = null,
windowInsets: WindowInsets = WideNavigationRailDefaults.windowInsets,
arrangement: Arrangement.Vertical = WideNavigationRailDefaults.arrangement,
contentPadding: PaddingValues = WideNavigationRailDefaults.ContentPadding,
content: @Composable () -> Unit,
)
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position. See the Modifier guide.
state: WideNavigationRailStateOptional
state: WideNavigationRailStateOptionalDefault: rememberWideNavigationRailState()
Whether the rail is expanded or collapsed.
shape: ShapeOptional
shape: ShapeOptionalDefault: WideNavigationRailDefaults.shape
Sets the outline of the rail.
colors: WideNavigationRailColorsOptional
colors: WideNavigationRailColorsOptionalDefault: WideNavigationRailDefaults.colors()
Sets rail and item colors. Make one with WideNavigationRailDefaults.colors for the rail, or WideNavigationRailItemDefaults.colors() for items.
header: @Composable (() -> Unit)?Optional
header: @Composable (() -> Unit)?OptionalDefault: null
Something above the items, like a menu button or a FAB.
windowInsets: WindowInsetsOptional
windowInsets: WindowInsetsOptionalDefault: WideNavigationRailDefaults.windowInsets
Space kept free for system bars. The default is usually right.
arrangement: Arrangement.VerticalOptional
arrangement: Arrangement.VerticalOptionalDefault: WideNavigationRailDefaults.arrangement
Where the items sit: at the top (default) or centered.
contentPadding: PaddingValuesOptionalSince 1.11
contentPadding: PaddingValuesOptionalSince 1.11Default: WideNavigationRailDefaults.ContentPadding
Space between the edge of the rail and its content.
content: @Composable () -> UnitRequired
content: @Composable () -> UnitRequiredThe items. Add one WideNavigationRailItem for each destination.
Types and parts
WideNavigationRailModalWideNavigationRailWideNavigationRailItem
See also
WideNavigationRailDefaults: default values and helper functions forWideNavigationRail.