androidx.compose.material3

NavigationRailItem

Composable function

A part of NavigationRail. See that page for an overview and examples.

Parameters

@Composable
fun NavigationRailItem(
    selected: Boolean,
    onClick: () -> Unit,
    icon: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    label: @Composable (() -> Unit)? = null,
    alwaysShowLabel: Boolean = true,
    colors: NavigationRailItemColors = NavigationRailItemDefaults.colors(),
    interactionSource: MutableInteractionSource? = null,
)

selected: BooleanRequired

Whether this item is the current destination. Usually index == selectedIndex.

onClick: () -> UnitRequired

Called when the item is clicked. Set your selected index and navigate here.

icon: @Composable () -> UnitRequired

The icon of the item.

enabled: BooleanOptional

Default: true

Set to false to make the item gray and not clickable.

label: @Composable (() -> Unit)?Optional

Default: null

The name of the destination. Keep it to one short word.

alwaysShowLabel: BooleanOptional

Default: true

Set to false to show the label only on the selected item.

colors: NavigationRailItemColorsOptional

Default: NavigationRailItemDefaults.colors()

Sets icon, label and indicator colors for selected, unselected and disabled items. Make one with NavigationRailItemDefaults.colors.

interactionSource: MutableInteractionSource?Optional

Default: 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 NavigationRail: modifier.

Parts

See also