androidx.compose.material3

WideNavigationRailItemSince 1.9

Composable function

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

Parameters

@Composable
fun WideNavigationRailItem(
    selected: Boolean,
    onClick: () -> Unit,
    icon: @Composable () -> Unit,
    label: @Composable (() -> Unit)?,
    railExpanded: Boolean,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    iconPosition: NavigationItemIconPosition = WideNavigationRailItemDefaults.iconPositionFor(railExpanded),
    colors: NavigationItemColors = WideNavigationRailItemDefaults.colors(),
    interactionSource: MutableInteractionSource? = null,
    indicatorPadding: PaddingValues = WideNavigationRailItemDefaults.indicatorPadding(railExpanded = railExpanded),
)

selected: BooleanRequired

Whether this item is the current destination.

onClick: () -> UnitRequired

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

icon: @Composable () -> UnitRequired

The icon of the item.

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

The name of the destination.

railExpanded: BooleanRequired

Whether the rail is expanded. Pass state.targetValue == WideNavigationRailValue.Expanded, so the item lays out to match.

enabled: BooleanOptional

Default: true

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

iconPosition: NavigationItemIconPositionOptional

Default: WideNavigationRailItemDefaults.iconPositionFor(railExpanded)

Where the icon sits: above the label, or before it. Default: above when collapsed, before when expanded.

colors: NavigationItemColorsOptional

Default: WideNavigationRailItemDefaults.colors()

Sets rail and item colors. Make one with WideNavigationRailDefaults.colors for the rail, or WideNavigationRailItemDefaults.colors() for items.

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.

indicatorPadding: PaddingValuesOptionalSince 1.11

Default: WideNavigationRailItemDefaults.indicatorPadding(railExpanded = railExpanded)

Space around the selection indicator.

Same as in WideNavigationRail: modifier.

Types and parts

See also