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
selected: BooleanRequiredWhether this item is the current destination. Usually index == selectedIndex.
onClick: () -> UnitRequired
onClick: () -> UnitRequiredCalled when the item is clicked. Set your selected index and navigate here.
icon: @Composable () -> UnitRequired
icon: @Composable () -> UnitRequiredThe icon of the item.
enabled: BooleanOptional
enabled: BooleanOptionalDefault: true
Set to false to make the item gray and not clickable.
label: @Composable (() -> Unit)?Optional
label: @Composable (() -> Unit)?OptionalDefault: null
The name of the destination. Keep it to one short word.
alwaysShowLabel: BooleanOptional
alwaysShowLabel: BooleanOptionalDefault: true
Set to false to show the label only on the selected item.
colors: NavigationRailItemColorsOptional
colors: NavigationRailItemColorsOptionalDefault: NavigationRailItemDefaults.colors()
Sets icon, label and indicator colors for selected, unselected and disabled items.
Make one with NavigationRailItemDefaults.colors.
interactionSource: MutableInteractionSource?Optional
interactionSource: MutableInteractionSource?OptionalDefault: 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
NavigationRailNavigationRailItem
See also
NavigationRailDefaults: default values and helper functions forNavigationRailItem.