Skip to main content

NavigationBar

A navigation bar lets people switch between the top-level destinations of an app on a compact screen. It follows the Material Design 3 Navigation bar specification.

Each destination is an icon over a label. A secondaryContainer pill behind the icon marks the active one. The bar is 80dp tall on a surfaceContainer background.

NavigationBar is a bar, not a navigator

NavigationBar renders the destinations and tells you which one the user pressed. It doesn't own screens, mount panels, or integrate with a navigator. Point it at the navigator you already use; see Wiring it to a navigator.

Usage​

Pass the destinations as items and read the selection from onValueChange. With no value prop, the bar tracks the active destination itself and starts on the first item.

import { NavigationBar } from '@rootnative/components'
import { mdiResolver } from '@rootnative/components/mdi'
import { ThemeProvider } from '@rootnative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { useState } from 'react'
import { Text, View } from 'react-native'

const DESTINATIONS = [
{ value: 'home', label: 'Home', icon: 'home-outline', selectedIcon: 'home' },
{ value: 'search', label: 'Search', icon: 'magnify' },
{ value: 'library', label: 'Library', icon: 'bookshelf' },
]

const PANELS = {
home: 'Fresh picks for you.',
search: 'Type to find anything.',
library: 'Everything you saved.',
}

function Screen() {
const [destination, setDestination] = useState('home')
return (
<View style={{ flex: 1 }}>
<View style={{ flex: 1, padding: 24 }}>
<Text>{PANELS[destination]}</Text>
</View>
<NavigationBar
items={DESTINATIONS}
value={destination}
onValueChange={setDestination}
insetBottom
/>
</View>
)
}

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<Screen />
</ThemeProvider>
</SafeAreaProvider>
)
}

MD3 recommends 3–5 destinations. The destinations split the row equally, whatever the count.

An item shows its selectedIcon while it is active. MD3 pairs an outlined icon at rest with its filled counterpart. Leave it off to keep the same icon in both states.

Selection​

value + onValueChange is the controlled form. Leave value off, and the bar tracks the selection itself, and starts on defaultValue or the first item. A navigation bar with nothing active looks broken, so there is no "no selection" state. onValueChange fires on every press, controlled or not.

Wiring it to a navigator​

NavigationBar stops at the bar, on purpose. With expo-router, drive it from the current route:

import { NavigationBar } from '@rootnative/components'
import { usePathname, useRouter } from 'expo-router'

const DESTINATIONS = [
{ value: '/home', label: 'Home', icon: 'home-outline', selectedIcon: 'home' },
{ value: '/search', label: 'Search', icon: 'magnify' },
]

function AppShellBar() {
const pathname = usePathname()
const router = useRouter()

return (
<NavigationBar
items={DESTINATIONS}
value={DESTINATIONS.find((d) => pathname.startsWith(d.value))?.value}
onValueChange={(value) => router.replace(value)}
insetBottom
/>
)
}

The same shape works for react-navigation. Render it as a custom tabBar and map state.index to value.

Label visibility​

labelVisibility controls when the destination labels show:

ValueMeaning
'always' (default)Every destination keeps its label
'selected'Only the label of the active destination is visible. It fades in on selection, and the inactive icons sit centred
'never'No labels. Every icon is centred

The label stays required on the item in every mode. It is also the screen-reader name of the destination.

The indicator​

The active indicator is a 56×32dp secondaryContainer pill behind the icon. On selection it fades in and expands from its centre on springDefaultSpatial. Under reduced motion, it goes to its end value at once; see Motion. The hover, press, and focus state layers paint inside the same pill shape, on active and inactive destinations alike.

Safe area​

A bar at the bottom must clear the home indicator. Pass insetBottom to wrap the row in a SafeAreaView that adds the bottom inset below the 80dp of the bar. Leave it off (the default) when an ancestor already applies the bottom edge, or the inset applies twice.

The side insets are on by default (insetSides). The bar pads its row by the left and right insets, and inside a Layout that pads the sides it pulls its background back through that padding, so in landscape the bar stays full-bleed and the destinations stay clear of the notch. Pass insetSides={false} for a bar nested inside content, where the pulled-out background would show beyond its container.

Overrides​

PropTarget
containerColorThe bar background
contentColorIcon and label color of inactive destinations
selectedContentColorIcon and label color of the active destination. The state layers derive from it again
indicatorColorThe active indicator pill
labelStyleThe label Text of every destination. It doesn't affect the icons
styleThe bar container

A disabled destination always uses the MD3 disabled treatment (38% content). No override changes that.

When you pass testID, each destination carries <testID>-item-<value>, and its indicator carries <testID>-item-<value>-indicator, so a test can assert on them.

Tokens​

TokenValue
ContainersurfaceContainer, elevation level 2
Height80dp (+ bottom inset with insetBottom)
Active indicator56×32dp pill, secondaryContainer, full corners
Icon24dp. Active onSecondaryContainer, inactive onSurfaceVariant
LabellabelMedium. Active secondary, inactive onSurfaceVariant
Indicator → label gap4dp
Item padding8dp horizontal. The destinations split the row equally

These are the Expressive-updated androidx tokens: the indicator is 56dp wide (not the pre-Expressive 64dp), and the active label is secondary (not onSurface). The 64dp-tall Expressive short bar is a possible 1.x variant. This bar uses the TallContainerHeight of Compose.

Accessibility​

  • The bar reports role="tablist", and each destination reports role="tab" with accessibilityState.selected. Pass accessibilityLabel to name the bar itself ("Main navigation").
  • The screen-reader name of a destination falls back to its label, also when labelVisibility hides the visible label. Set accessibilityLabel on the item to override it.
  • A disabled destination exposes accessibilityState.disabled and stops responding.
  • On the web, a destination shows a keyboard focus ring (secondary, 3dp) around the indicator pill, driven by the same focus-visible state as the rest of the library.

Props​

PropTypeDefaultRequiredDescription
itemsNavigationBarItem[]-YesThe destinations to render. MD3 recommends 3–5.
valuestring-NoValue of the active destination (controlled).
defaultValuestring-NoValue of the initially active destination (uncontrolled). Defaults to the first item — a navigation bar with nothing active reads as broken.
onValueChange(value: string) => void-NoCalled with the value of the destination that was pressed.
labelVisibilityenumalwaysNoWhen destination labels are shown.
insetBottombooleanNoWhen `true`, wraps the row in a SafeAreaView that adds the bottom inset below the bar's 80dp, so it clears the home indicator. Leave it off when an ancestor (e.g. `Layout` with a `bottom` edge) already handles it.
insetSidesbooleanNoWhen `true`, pads the row by the left and right safe-area insets, and inside a `Layout` that pads the sides pulls the background back through that padding. In landscape the bar stays full-bleed and the destinations stay clear of the notch; in portrait both insets are 0. Set it to `false` for a bar nested inside content, where the pulled-out background would show beyond its container.
containerColorstringsurfaceContainerNoOverride the bar background.
contentColorstringonSurfaceVariantNoOverride the icon and label color of inactive destinations.
selectedContentColorstringonSecondaryContainer (icon) / secondary (label)NoOverride the icon and label color of the active destination. State-layer colors are derived from it automatically.
indicatorColorstringsecondaryContainerNoOverride the active indicator pill color.
labelStyleStyleProp<TextStyle>-NoStyle applied to every destination's label `Text` — does not affect the icons.
styleStyleProp<ViewStyle>-NoStyle applied to the bar container.
accessibilityLabelstring-NoScreen-reader label for the bar itself.
testIDstring-NoTest id applied to the bar container. Each destination carries `<testID>-item-<value>` and its indicator `<testID>-item-<value>-indicator`.