Bottom Navigation
FreeThe phone app bar: three to five destinations as real links with an icon and a label, aria-current on the page you are on, 48 px targets, count badges and dots, padded clear of the home indicator with env(safe-area-inset-bottom). Fixed (with its height reserved), sticky in a scroller, or static; hidden from a breakpoint up. The same MenuItem model as the sidebar, and no router dependency.
import { SvBottomNavComponent } from '@styloviz/sidebar-nav';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
One model, two renderers
<!-- The same MenuItem[] on a phone and a desktop: the bar hides from md up, the sidebar below it. --> <sv-sidebar-nav class="hidden md:flex" [menuGroups]="[{ groupLabel: 'App', items: destinations }]" [activeRoute]="router.url" /> <sv-bottom-nav [items]="destinations" [activeRoute]="router.url" hideFrom="md" />
Badges and dots
destinations: MenuItem[] = [ { label: 'Home', route: '/app', icon: 'home' }, { label: 'Inbox', route: '/app/inbox', icon: 'inbox', badge: '12' }, { label: 'Alerts', route: '/app/alerts', icon: 'bell', dot: true }, { label: 'Billing', route: '/app/billing', icon: 'credit-card', badge: '!', badgeColor: 'warning' }, ];
Wired to the Angular router
// app.config.ts — the bar renders <a href> through SvLinkAdapter; provide a router one once. provideSvLinkAdapter(() => { const router = inject(Router); const tree = (t: SvLinkTarget) => (typeof t === 'string' ? router.parseUrl(t) : router.createUrlTree([...t])); return { kind: 'angular-router', href: (t) => router.serializeUrl(tree(t)), navigate: (t) => { void router.navigateByUrl(tree(t)); return true; }, }; }), <!-- and bind where the reader is --> <sv-bottom-nav [items]="destinations" [activeRoute]="url()" />
Inside a scroll container
<div class="h-full overflow-y-auto" svRevealFocus> … <sv-bottom-nav position="sticky" labelVisibility="active" [items]="destinations" [activeRoute]="url()" /> </div>
When to use
The primary navigation of a phone layout — a PWA, a mobile web dashboard, a store front — with three to five top-level destinations. Alongside a desktop sidebar fed the same destinations, hidden from the breakpoint where the sidebar appears. Not for switching views on one page (use Tabs or a Segmented Control) and not for more than five destinations (put the rest behind a "More" destination or in the sidebar).
Compare with
- Sidebar Nav — Sidebar Nav is the desktop renderer of the same MenuItem model — groups, sub-pages and a collapsed rail. Bottom Navigation is the phone bar for three to five top-level destinations; feed both the same array and hide each where the other shows.
- Tabs — Tabs switch panels on the same page and use the tablist keyboard model. Bottom Navigation moves between pages: real links with aria-current, never tabs.
- Dock — Dock is an icon-only launcher bar on any edge of a container — one tab stop with arrow keys, labels on hover and focus, magnification. Bottom Navigation is the phone app bar, with visible labels and Tab between links.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| items | readonly MenuItem[] | [] | The destinations — three to five. Each `MenuItem` needs `label`, `route` and `icon` (an icon-library name the app has registered); `badge`, `badgeColor`, `dot`, `id` and `external` are honoured. |
| activeRoute | string | '' | The path the reader is on, so one destination is marked current. Controlled — a routed host writes `[activeRoute]="router.url"`. |
| position | BottomNavPosition | 'fixed' | Where the bar sits. |
| hideFrom | BottomNavBreakpoint | null | null | Hide the bar from this breakpoint up — the desktop has a sidebar for the same destinations. `null` shows it at every width. |
| labelVisibility | BottomNavLabelVisibility | 'always' | Show every label, or only the current destination's. |
| reserveSpace | boolean | true | With `position="fixed"`, render an in-flow spacer of the bar's height, so the end of the page is never hidden behind it. |
| ariaLabel | string | '' | The `<nav>` landmark's accessible name. Defaults to the `navigation` label ('Main navigation'). |
| surfaceId | string | null | null | Names this bar in the navigation stream when a page has several. |
| labels | Partial<SvSidebarNavLabels> | {} | Per-instance overrides for the package labels. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| itemSelected | BottomNavSelection | A destination was picked (a plain click or tap; a modified click opens elsewhere and is not reported). |
Customization & theming
Three positions: `fixed` (pinned to the viewport, reserving its height in the flow with `reserveSpace`), `sticky` (bottom of its own scroller) and `static`. `hideFrom` (`sm` · `md` · `lg`) hides it from a breakpoint up. Badges take `badgeColor` (primary · accent · warning · danger — danger by default) and render as a count pill; `dot` draws an activity dot. The current item draws the `solid` weight of its icon and the `primary-*` tokens, so a theme that remaps primary recolours it. Icons are icon-library names the app registers (`provideSvIcons` or `registerSvIcons`); labels come from the `sidebarNav` namespace (`navigation`, `newActivity`, `external`).
Best practices
Do: Bind `[activeRoute]="router.url"`. The longest matching route is current, on segment boundaries, so a detail page keeps its section lit. Do: Add `viewport-fit=cover` to the page's viewport meta, so `env(safe-area-inset-bottom)` reports the home indicator on notched phones. Don't: Don't put actions ("Compose", "New") in the bar — it is for places. A floating action button or the page header holds actions. Don't: Don't use more than five items; the bar warns once in development past five. Tip: `labelVisibility="active"` shows only the current label — the others stay as the links' accessible names, so nothing is lost to a screen reader.
Accessibility
A `<nav>` landmark named by `ariaLabel` (default "Main navigation"), with a list of real `<a href>` links — Tab moves between them, Enter follows one. No `role="tab"`: a bar that changes pages is navigation, not a tablist. The current destination carries `aria-current="page"`. Every link is at least 48 × 48 px (WCAG 2.5.8 asks for 24). A badge is drawn on the icon but read after the label ("Inbox, 12"); a dot is read as "new activity"; an external destination says it opens in a new tab. A fixed bar marks itself `data-sv-sticky="page-bottom"`, so the browser keeps a focused control from being scrolled under it (WCAG 2.4.11).
Feedback on Bottom Navigation
Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.