We just launched Compose Examples featuring over 150+ components! Check it out →

WideNavigationRailItem

Common

Component in Material 3 Compose

Material Design wide navigation rail item.

It's recommend for navigation items to always have a text label. A [WideNavigationRailItem] always displays labels (if they exist) when selected and unselected.

The [WideNavigationRailItem] supports two different icon positions, top and start, which is controlled by the [iconPosition] param:

  • If the icon position is [NavigationItemIconPosition.Top] the icon will be displayed above the label. This configuration should be used with collapsed wide navigation rails.
  • If the icon position is [NavigationItemIconPosition.Start] the icon will be displayed to the start of the label. This configuration should be used with expanded wide navigation rails.

However, if an animated item is desired, the [iconPosition] can be controlled via the expanded value of the associated [WideNavigationRail]. By default, it'll use the [railExpanded] to follow the configuration described above.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.material3:material3:1.4.0-alpha01")
}

Overloads

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

Parameters

namedescription
selectedwhether this item is selected
onClickcalled when this item is clicked
iconicon for this item, typically an [Icon]
labeltext label for this item
modifierthe [Modifier] to be applied to this item
enabledcontrols the enabled state of this item. When false, this component will not respond to user input, and it will appear visually disabled and disabled to accessibility services.
railExpandedwhether the associated [WideNavigationRail] is expanded or collapsed
iconPositionthe [NavigationItemIconPosition] for the icon
colors[NavigationItemColors] that will be used to resolve the colors used for this item in different states. See [WideNavigationRailItemDefaults.colors]
interactionSourcean optional hoisted [MutableInteractionSource] for observing and emitting [Interaction]s for this item. You can use this to change the item's appearance or preview the item in different states. Note that if null is provided, interactions will still happen internally.
by @alexstyl