Navigation bar
Expressive3–5 destinations along the bottom of compact and medium windows, stacked or inline.
import { NavigationBar, NavigationBarItem } from '@windmorph/react';Props
NavigationBar 11 props
Text
Also accepts the root element's HTML attributes (id, data-*, event handlers).
NavigationBarItem 22 props
Events
Also accepts every <a> or <button> attribute.
Tokens
M3's component tokens as CSS variables. Each is unset until you set it, on :root, a theme or any ancestor, and falls back to the default shown. The root carries data-variant (and data-size where it has sizes), which picks the variables that apply. See Component tokens in the Customisation guide.
| Variable | Default | Paints | Compose |
|---|---|---|---|
--md-comp-nav-bar-container-color | var(--md-sys-color-surface-container) | The bar. | NavigationBarTokens.ContainerColor |
--md-comp-nav-bar-item-active-indicator-color | var(--md-sys-color-secondary-container) | The current item's pill. | NavigationBarTokens.ItemActiveIndicatorColor |
--md-comp-nav-bar-item-active-icon-color | var(--md-sys-color-on-secondary-container) | The current item's icon. | NavigationBarTokens.ItemActiveIconColor |
--md-comp-nav-bar-item-inactive-icon-color | var(--md-sys-color-on-surface-variant) | The other items’ icons. | NavigationBarTokens.ItemInactiveIconColor |
--md-comp-nav-bar-item-active-label-text-color | var(--md-sys-color-secondary)Varies with layout. | The current item's label: `secondary` below its icon, `on-secondary-container` beside it (in the pill). | NavigationBarTokens.ItemActiveLabelTextColor |
--md-comp-nav-bar-item-inactive-label-text-color | var(--md-sys-color-on-surface-variant) | The other items’ labels. | NavigationBarTokens.ItemInactiveLabelTextColor |
Spec status
Built to the M3 Expressive navigation bar spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.
| Item | Status | Details |
|---|---|---|
| Flexible navigation bar | Built | Variant · Stacked, Inline |
| Navigation item layout: vertical | Built | Configuration · Stacked |
| Navigation item layout: horizontal (medium windows) | Built | Configuration · Inline |
| Badges on destinations | Built | Use case · Stacked |
| Hide on scroll | Built | Use case · Hide on scroll |
arrangement | Extension | Shares the width equally or centres the items, for either item layout (Compose's ShortNavigationBarArrangement). |
onReselect | Extension | Runs when the current destination is pressed again, for resetting its scroll position to the top. |
| Navigation bar (baseline) | Not built | Deprecated in M3 Expressive; the flexible bar replaces it. |
Navigation item layout: vertical
BuiltConfiguration · Stacked
Navigation item layout: horizontal (medium windows)
BuiltConfiguration · Inline
Badges on destinations
BuiltUse case · Stacked
Hide on scroll
BuiltUse case · Hide on scroll
ExtensionarrangementShares the width equally or centres the items, for either item layout (Compose's
ShortNavigationBarArrangement).
ExtensiononReselectRuns when the current destination is pressed again, for resetting its scroll position to the top.
Navigation bar (baseline)
Not builtDeprecated in M3 Expressive; the flexible bar replaces it.
Bundle size
Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.
NavigationBar,NavigationBarItem: 24.8 kB
Differences from Compose
- This is Compose's short / flexible navigation bar (
ShortNavigationBar), which replaces the original navigation bar; it is at least 64pxsurface-containerwith no elevation. arrangement="centered"reproduces Compose's side padding of (100% − 10% × (n + 3)) / 2 for up to 6 stacked items. Inline items are sized to their content, 8px apart (a provisional gap; the spec gives no value).- The pill grows from its centre on the default spatial spring, and the state layer and focus ring are pill-shaped, as in Compose's indicator ripple: a press ripples through the pill from the press point. Items fill the bar's height, so the whole 64px is the touch target and inline pills sit in its middle.