Navigation rail
ExpressiveTop-level destinations along the start edge, collapsed or expanded, in medium windows.
import { NavigationRail, NavigationRailItem, useNavigationRail } from '@windmorph/react';Keyboard
| Key | Action | Where |
|---|---|---|
| Tab | Moves focus through the header (a menu button, a FAB), then each item in turn. | |
| Arrow Up or Arrow Down | Moves focus to the previous or next item, wrapping, without choosing it. | |
| Home or End | Moves focus to the first or last item. | |
| Enter | Opens the focused destination. On a button item Space does the same. | |
| Escape | Collapses the expanded rail.Modal rail | Modal rail |
- The arrow keys skip disabled items.
- Pressing the current destination again calls
onReselect, where the page can scroll back to the top.
Screen reader
- Role
- A
navigationlandmark (nav); each item is alink(href) or abutton. The expanded modal rail is adialogholding the header and anav. - Accessible name
- The rail, and the modal dialog, are named by
aria-labeloraria-labelledby, which the types require. Each item is named by its label. - States announced
- The current destination has
aria-current="page". A disabled item is announced as disabled.
- Icons, the active indicator and the state layer are hidden from assistive tech (
aria-hidden). - A
badgedescribes its item (aria-describedby), read after the name: its text, itslabel, orbadgeLabel("3 new messages"). A small (dot) badge reads "New notification". - While the modal rail is open, the rest of the page is hidden from assistive tech.
Focus
- The header and the items are in the Tab order in their visual order. A disabled item can't be focused.
- Keyboard focus shows M3's focus indicator, a 3px
secondaryoutline 2px outside the pill. Pointer presses show no ring. - The modal rail moves focus to its first interactive element when it opens (the menu button, the FAB or the first destination) and keeps focus inside. Escape, a press outside, or choosing an item collapses it and returns focus to where it was.
Touch target
- A collapsed item is the rail's full 96px width and at least 64px tall.
- An expanded item is the whole row, at least 56px tall, larger than the pill that shows the state.
Motion
- Under reduced motion the rail expands and collapses at once, and the active indicator fades in whole instead of expanding from the icon's centre. The press ripple appears at full size without growing.
- A
modalrail fades in and out at its full width instead of growing or sliding from the edge. - With
indicatorMotion="slide", the pill fades in place under reduced motion instead of sliding.
What you need to do
- Name the rail with
aria-labeloraria-labelledby, distinct from other navigation on the page. - Give every item a short visible label. Labels wrap between words, so keep the full text; only a single word too wide for its item at large text sizes ends with an ellipsis.
- Give a menu button in
headeranaria-labelthat says what it does ("Expand navigation" / "Collapse navigation"). - Mark the current destination with
current, and give it a filledcurrentIconwhere the icon set has one, so the state does not rest on colour alone. - Scroll the page to the top in
onReselect, as M3 asks.