Skip to the content

NavBar

NavBar is the bottom navigation bar of a phone or tablet shell: three to five top-level destinations, each a glyph over a short label. The current item is tinted and marked aria-current="page". The bar pads its bottom by env(safe-area-inset-bottom) to clear the home indicator.
Navigation

When to use

Use when
  • You link the app's three to five top-level sections on a phone or an upright tablet.
  • Each destination is a page (a route).
  • You pair it with a Tabs row in mode="nav" for the pages inside a section.
Avoid when
  • There are more than five destinations — keep four and move the rest behind a "More" Sheet.
  • The viewport is wide — hand navigation to a side rail and stop rendering the bar from md up.
  • The items are actions (save, share) or switch content in place — use buttons or content-mode Tabs.

Usage

Derive current from the router's pathname. A development warning fires outside the three-to-five range. Click an item below (the demo keeps current in state instead of navigating).

import { NavBar } from '@apollion-dsi/core/elements/nav-bar';
import { clock, cog, desktop, search } from '@apollion-dsi/core/icons';

<NavBar
  aria-label="Main"
  items={[
    { label: 'Overview', icon: desktop, href: '/', current: pathname === '/' },
    { label: 'Search', icon: search, href: '/search', current: pathname === '/search' },
    { label: 'Activity', icon: clock, href: '/activity', current: pathname === '/activity' },
    { label: 'Settings', icon: cog, href: '/settings', current: pathname === '/settings' },
  ]}
/>;

Routing

Items with href or to render as links — a native <a> by default. Pass the router's link component once as linkAs, or per item as as. An item with only onClick renders a <button type="button">.

import NextLink from 'next/link';

<NavBar aria-label="Main" linkAs={NextLink} items={items} />;

Placement

The bar is in flow by default, so the shell places it (the last grid row, a sticky footer). fixed pins it to the bottom of the viewport on the sticky z-index layer; reserve the same space at the end of the scrolling content. The safe-area inset applies only when the page's viewport meta includes viewport-fit=cover.

Accessibility

  • A nav landmark named by the required aria-label; give each nav on the page its own name.
  • Items are a list of links or buttons named by their visible label; the glyph is aria-hidden.
  • The current item is marked by more than color: a bold label and a wash behind its glyph.
  • Every item is at least 56px tall and shows an inset :focus-visible ring.

Properties

See also