NavigationRail
A navigation rail lets people switch between the top-level destinations of an app on a medium or expanded screen, where a bottom bar would waste width. It follows the Material Design 3 Navigation rail specification.
Each destination is an icon over a label. A secondaryContainer pill behind the icon marks the
active one. The rail is 80dp wide on a surface background, and an optional header above the
destinations holds the menu button and the FAB.
NavigationRail renders the destinations and tells you which one the user pressed. It doesn't
own screens or integrate with a navigator. Drive it the same way as
NavigationBar.
Usage
Pass the destinations as items and read the selection from onValueChange. With no value
prop, the rail tracks the active destination itself and starts on the first item. Place it at
the start of a row that fills the screen height.
import { FAB, IconButton, NavigationRail } 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', badge: 3 },
]
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, flexDirection: 'row' }}>
<NavigationRail
items={DESTINATIONS}
value={destination}
onValueChange={setDestination}
header={
<View style={{ alignItems: 'center', gap: 8 }}>
<IconButton icon="menu" accessibilityLabel="Open menu" />
<FAB icon="pencil-outline" variant="tertiary" accessibilityLabel="Compose" />
</View>
}
/>
<View style={{ flex: 1, padding: 24 }}>
<Text>{PANELS[destination]}</Text>
</View>
</View>
)
}
export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider iconResolver={mdiResolver}>
<Screen />
</ThemeProvider>
</SafeAreaProvider>
)
}
MD3 recommends 3–7 destinations. An item has the same shape as a NavigationBarItem, so one
array can feed a NavigationBar on a compact window and a NavigationRail on a wider one.
See Responsive.
Selection
value + onValueChange is the controlled form. Leave value off, and the rail tracks the
selection itself, and starts on defaultValue or the first item. A rail with nothing active
looks broken, so there is no "no selection" state.
Header
header renders above the destinations, with an 8dp gap below it. MD3 puts the menu
IconButton there, and the FAB of the screen below it when the screen has one. The header
stays at the top, whatever align is.
Alignment
align places the destinations along the height of the rail:
| Value | Meaning |
|---|---|
'top' (default) | Destinations start right below the header |
'center' | Destinations sit in the middle of the remaining height |
'bottom' | Destinations sit at the bottom |
Label visibility
labelVisibility controls when the destination labels show:
| Value | Meaning |
|---|---|
'always' (default) | Every destination keeps its label |
'selected' | Only the label of the active destination is visible |
'never' | No labels. The indicator grows to a 56dp circle |
The label stays required on the item in every mode. It is also the screen-reader name of the destination.
Overrides
| Prop | Target |
|---|---|
containerColor | The rail background |
contentColor | Icon and label color of inactive destinations |
selectedContentColor | Icon and label color of the active destination. The state layers derive from it again |
indicatorColor | The active indicator pill |
labelStyle | The label Text of every destination. It doesn't affect the icons |
style | The rail container |
A disabled destination always uses the MD3 disabled treatment (38% content). No override changes that.
When you pass testID, the destinations column carries <testID>-destinations, each
destination <testID>-item-<value>, and its indicator <testID>-item-<value>-indicator.
Tokens
| Token | Value |
|---|---|
| Container | surface, elevation level 0, 80dp wide |
| Padding | 4dp top and bottom, 4dp between destinations, 8dp below the header |
| Destination | 80dp wide, at least 56dp tall |
| Active indicator | 56×32dp pill, secondaryContainer, full corners; 56×56dp with no labels |
| Icon | 24dp. Active onSecondaryContainer, inactive onSurfaceVariant |
| Label | labelMedium. Active secondary, inactive onSurfaceVariant |
The destination tokens are the ones that NavigationBar paints, so the two components agree on
the active destination. The Expressive 96dp collapsed wide rail is a possible 1.x variant. This
rail uses the NavigationRail of Compose.
Accessibility
- The destinations column reports
role="tablist", and each destination reportsrole="tab"withaccessibilityState.selected. PassaccessibilityLabelto name the rail itself ("Main navigation"). - The screen-reader name of a destination falls back to its label, also when
labelVisibilityhides the visible label. SetaccessibilityLabelon the item to override it. - A disabled destination exposes
accessibilityState.disabledand stops responding. - On the web, a destination shows a keyboard focus ring (
secondary, 3dp) around the indicator pill.
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
items | NavigationBarItem[] | - | Yes | The destinations to render. MD3 recommends 3–7. |
value | string | - | No | Value of the active destination (controlled). |
defaultValue | string | - | No | Value of the initially active destination (uncontrolled). Defaults to the first item — a rail with nothing active reads as broken. |
onValueChange | (value: string) => void | - | No | Called with the value of the destination that was pressed. |
labelVisibility | enum | always | No | When destination labels are shown. |
align | enum | top | No | Where the destinations sit along the rail. The header, when given, stays at the top in every mode. |
header | ReactNode | - | No | Content above the destinations: a menu `IconButton`, a `FAB`, or both in a `Column`. MD3 places the FAB here when the screen has one. |
containerColor | string | surface | No | Override the rail background. |
contentColor | string | onSurfaceVariant | No | Override the icon and label color of inactive destinations. |
selectedContentColor | string | onSecondaryContainer (icon) / secondary (label) | No | Override the icon and label color of the active destination. State-layer colors are derived from it automatically. |
indicatorColor | string | secondaryContainer | No | Override the active indicator pill color. |
labelStyle | StyleProp<TextStyle> | - | No | Style applied to every destination's label `Text` — does not affect the icons. |
style | StyleProp<ViewStyle> | - | No | Style applied to the rail container. |
accessibilityLabel | string | - | No | Screen-reader label for the rail itself. |
testID | string | - | No | Test id applied to the rail container. The destinations column carries `<testID>-destinations`, each destination `<testID>-item-<value>`, and its indicator `<testID>-item-<value>-indicator`. |