Navigation bar

Switches between three to five top level destinations on compact windows.

When to use

The short navigation bar is the Expressive navigation bar. It is shorter than the baseline bar, supports icons beside labels and a centered arrangement for wider windows. The baseline NavigationBar is still available.

Use a bar on compact windows only. From the medium size class on, switch to a navigation rail.

Playground

The interactive page has a playground with live property controls for this component and generated code.

Examples

Short navigation bar

Expressive. Select a destination.

var selected by rememberSaveable { mutableIntStateOf(0) }
val destinations = listOf(
    Icons.Rounded.Home to "Home",
    Icons.Rounded.Search to "Search",
    Icons.Rounded.LibraryMusic to "Library",
)

ShortNavigationBar {
    destinations.forEachIndexed { index, (icon, label) ->
        ShortNavigationBarItem(
            selected = selected == index,
            onClick = { selected = index },
            icon = { Icon(icon, contentDescription = null) },
            label = { Text(label) },
        )
    }
}

Baseline navigation bar

var selected by rememberSaveable { mutableIntStateOf(0) }
val destinations = listOf(
    Icons.Rounded.Home to "Home",
    Icons.Rounded.Search to "Search",
    Icons.Rounded.LibraryMusic to "Library",
)

NavigationBar {
    destinations.forEachIndexed { index, (icon, label) ->
        NavigationBarItem(
            selected = selected == index,
            onClick = { selected = index },
            icon = { Icon(icon, contentDescription = null) },
            label = { Text(label) },
        )
    }
}

Parameters

NameTypeDefaultDescription
arrangementShortNavigationBarArrangementEqualWeightEqualWeight fills the width, Centered groups items in the middle.
selectedBooleanItem parameter. Marks the active destination.
icon / label@ComposableItem parameters. The label may be null for icon only items.
iconPositionNavigationItemIconPositionTopTop stacks icon above label, Start puts them side by side.

Guidelines

Do:

Don't:

Accessibility

Related components