NavigationRail

fun NavigationRail(modifier: Modifier = Modifier, state: NavigationRailState? = null, header: @Composable ColumnScope.() -> Unit? = null, color: Color = MiuixTheme.colorScheme.surface, showDivider: Boolean = true, defaultWindowInsetsPadding: Boolean = true, minWidth: Dp = NavigationRailDefaults.MinWidth, expandedWidth: Dp = NavigationRailDefaults.ExpandedWidth, expandContentDescription: String = NavigationRailDefaults.ExpandContentDescription, collapseContentDescription: String = NavigationRailDefaults.CollapseContentDescription, scrollState: ScrollState = rememberScrollState(), content: @Composable ColumnScope.() -> Unit)

A NavigationRail that is suitable for wide screens.

When a non-null state is provided, the rail becomes expandable: a built-in toggle button is shown at the top (aligned to the start when expanded), the rail animates between minWidth and expandedWidth, and its items switch to a horizontal icon-and-label layout with a highlighted pill behind the selected item. When state is null the rail keeps its classic collapsed layout with no toggle button.

Parameters

modifier

The modifier to be applied to the NavigationRail.

state

Controls the expanded/collapsed state; pass a rememberNavigationRailState to make the rail expandable, or null (default) for the classic non-expandable rail. Keep the same nullness across window size changes and drive it via NavigationRailState.expand / NavigationRailState.collapse; flipping between null and non-null at runtime swaps the item layout in a single frame without animation.

header

The header of the NavigationRail, usually a FloatingActionButton or a logo.

color

The color of the NavigationRail.

showDivider

Whether to show the divider line between the NavigationRail and the content.

defaultWindowInsetsPadding

whether to apply default window insets padding to the NavigationRail.

minWidth

The minimum width of the NavigationRail, used for the collapsed state.

expandedWidth

The width of the NavigationRail when state is expanded.

expandContentDescription

The accessible description of the built-in toggle while the rail is collapsed; override it to localize the announcement.

collapseContentDescription

The accessible description of the built-in toggle while the rail is expanded; override it to localize the announcement.

scrollState

The ScrollState of the rail's scrollable content column.

content

The content of the NavigationRail, usually NavigationRailItems.