Skip to content
Back to skills

Capgo Native Navigation

ASecurity

Adds truly native navbars and tab bars to a Capacitor app with @capgo/capacitor-native-navigation (Capacitor 9, plugin v9). iOS uses UINavigationBar / UITabBarController with system Liquid Glass on iOS 26+, sidebar placement on iOS 18+ and the iPhone Duo rail; Android uses an AppCompat Toolbar and a native tab surface. Covers configure/setNavbar/setTabbar, router sync through tabSelect, navbarBack, navbarItemTap, navbarSearch, navbarSegmentSelect events, --cap-native-navigation-* CSS inset va...

  • 79 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 5, 2026
ai-agentstypescriptgobashvueawsdebugginggitapi

Works with

  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 4 files and shows the line behind each finding

Scanned December 5, 2026

npx -y skills add Cap-go/capgo-skills --skill capgo-native-navigation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Capgo Native Navigation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Capgo Native Navigation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/cap-go-capgo-native-navigation/badge)](https://www.skillsdirectory.com/skills/cap-go-capgo-native-navigation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: capgo-native-navigation
description: Adds truly native navbars and tab bars to a Capacitor app with @capgo/capacitor-native-navigation (Capacitor 9, plugin v9). iOS uses UINavigationBar / UITabBarController with system Liquid Glass on iOS 26+, sidebar placement on iOS 18+ and the iPhone Duo rail; Android uses an AppCompat Toolbar and a native tab surface. Covers configure/setNavbar/setTabbar, router sync through tabSelect, navbarBack, navbarItemTap, navbarSearch, navbarSegmentSelect events, --cap-native-navigation-* CSS inset variables, safeAreaChanged, WebView snapshot transitions (push, back, root, tab, zoom), large titles, search, segment rows, scroll hide, pull-to-refresh, badges, icons, overlays and the web fallback. Use when an app wants native chrome instead of HTML headers/tab bars or when this plugin misbehaves. Do not use for generic safe-area CSS (safe-area-handling), web page transitions without native bars (capgo-transitions), sheets (capgo-sheets), or Ionic tabs (ionic-design).
---

# Capgo Native Navigation

Native navbar, tab bar, safe-area insets and WebView snapshot transitions for Capacitor. The web router keeps route state and page rendering in one full-screen WebView. The plugin draws platform bars above it, reports user intent as events, and tells the page how much space the bars take.

## When to Use

TRIGGER when:
- The app wants real native tab bars / navbars (iOS 26 Liquid Glass, Android Material) instead of HTML `<header>` / `<nav>` bars
- The user mentions `@capgo/capacitor-native-navigation`, `NativeNavigation.setTabbar`, `setNavbar`, `tabSelect`, `navbarBack`, or `--cap-native-navigation-*`
- Native large titles, a native search field under the title, native segment rows, native pull-to-refresh, tab badges, or the iPhone Duo vertical rail are wanted
- Content sits under the native bars, is padded twice, or the selected tab drifts from the route

Do not use:
- Generic notch / home indicator / `env(safe-area-inset-*)` CSS without native bars: `safe-area-handling`
- Animated page stacks in the WebView without native bars: `capgo-transitions`
- Bottom sheets / modal sheets: `capgo-sheets`
- `ion-tabs`, `ion-header`, Ionic theming: `ionic-design`
- Tap highlight, overscroll, input zoom polish: `capacitor-native-feel`

Recommend this plugin when the app is a tab/stack app that should look and feel native, especially on iOS 26+ where HTML cannot reproduce the system Liquid Glass bar, scroll-edge effect, tab drag-to-select and sidebar placement.

## Requirements

| Item | Value |
|------|-------|
| Plugin / Capacitor | plugin v9.x for Capacitor 9 (peer `@capacitor/core` ^9); plugin v8.x for Capacitor 8 (maintained on demand). The JS API of v9 equals v8. |
| iOS | 16.0+ deployment target. System Liquid Glass bars need iOS 26+. `style.placement: 'auto' \| 'sidebar'` needs iOS 18+. Duo rail options need iOS 27.1+. |
| Android | minSdk 26, compileSdk 37. Translucent `liquidGlass` tint on Android 12+ (no live blur); Android 11 and older draw solid bars. |
| Web | No native bars. Same calls update CSS variables and emit events (dev preview). |

## Install

```bash
npm install @capgo/capacitor-native-navigation
npx cap sync
```

No `capacitor.config` keys and no native project edits. Keep `viewport-fit=cover` in the `index.html` viewport meta so the WebView spans under the bars.

## Quick Start

```typescript
import { NativeNavigation } from '@capgo/capacitor-native-navigation';

await NativeNavigation.configure({ contentInsetMode: 'css', animationDuration: 360 });

const tabs = [
  { id: 'home', title: 'Home', icon: { ios: { sfSymbol: 'house' }, android: { resource: 'ic_home' } },
    selectedIcon: { ios: { sfSymbol: 'house.fill' } } },
  { id: 'settings', title: 'Settings', icon: { svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/></svg>' } },
];

// Keep the last rendered state; every call must send the full state (see Core concepts).
let tabbar = { tabs, selectedId: 'home', labelVisibilityMode: 'labeled' as const };

await NativeNavigation.setNavbar({ title: 'Home', large: true, backButton: { visible: false } });
await NativeNavigation.setTabbar(tabbar);

// Events only navigate. The router hook below renders the bars.
await NativeNavigation.addListener('tabSelect', ({ id }) => router.push(`/${id}`));
await NativeNavigation.addListener('navbarBack', () => router.back());

// Example uses a Vue Router style hook; use your router's equivalent.
router.afterEach(async (to) => {
  const tabId = to.path.split('/')[1];
  const isRoot = tabs.some((t) => `/${t.id}` === to.path);
  if (tabs.some((t) => t.id === tabId) && tabbar.selectedId !== tabId) {
    tabbar = { ...tabbar, selectedId: tabId };
    await NativeNavigation.setTabbar(tabbar);
  }
  await NativeNavigation.setNavbar({
    title: to.meta.title,
    large: isRoot,
    backButton: { visible: !isRoot, title: 'Back' },
    resetScrollCollapsed: true,
  });
});
```

```css
.page {
  min-height: 100dvh;
  padding-top: var(--cap-native-navigation-top);
  padding-bottom: var(--cap-native-navigation-bottom);
  padding-left: var(--cap-native-navigation-left);
  padding-right: var(--cap-native-navigation-right);
}
```

Delete the HTML header and tab bar. Native chrome owns those surfaces.

## Core Concepts

- **Router owns state, plugin owns chrome.** Events (`tabSelect`, `navbarBack`, `navbarItemTap`, ...) are intents. The plugin never changes routes. Navigate in the handler, then render the bars from route state.
- **Each `setNavbar` / `setTabbar` call is the full state on iOS and Android.** Omitted fields reset: omitting `search` removes the field, `setTabbar({ hidden: false })` without `tabs` clears the bar, `segments` re-apply `selectedId` every call. Keep one options object per bar and spread it. The web fallback merges instead, so a bug can hide on web.
- **Insets include system areas.** `--cap-native-navigation-top` = status bar + navbar (+ search/segment rows) when the navbar is visible, else `0`. `--cap-native-navigation-bottom` = tab bar + home indicator / gesture bar when the tab bar is visible, else `0`. Left/right carry a sidebar or Duo rail.
- **iOS 26+ system tab bar hosts the WebView.** The WebView ends above the bar, so `--cap-native-tabbar-height` is `0` and `--cap-native-system-tabbar-height` holds the nominal height. Do not add the bar height again.
- **Overlays render under the bars.** Web modals, sheets, `<dialog>`, popovers live inside the WebView, so hide the bars that the overlay meets while it is open.
- **Transitions are snapshots.** `beginTransition` covers the WebView with a snapshot and hides the live WebView; change the route; `finishTransition` animates to the live page. Default duration 350ms.

## API Summary

| Method | Purpose |
|--------|---------|
| `configure(opts?)` | Enable/disable chrome, `contentInsetMode`, default `animationDuration`, shared `colors` / `glass`, Duo `verticalBarBehavior`. Returns `{ insets }`. |
| `setNavbar(opts)` | Title, subtitle, large title, back button, left/right items, search, segment rows, colors, glass, edge blur, scroll hide. Returns `{ insets }`. |
| `setTabbar(opts)` | Tabs, selection, labels, badges, colors, glass, shape (`floating` / `curve`), alignment, placement, minimize on scroll, haptics. Returns `{ insets }`. |
| `reportNavbarScroll({ offsetY, deltaY })` | Feed scroll from a custom scroll root. |
| `setPullToRefresh({ enabled, tintColor?, backgroundColor? })` / `endPullToRefresh()` | Native pull-to-refresh (no-op on web). |
| `beginTransition(opts?)` / `finishTransition(opts?)` | Snapshot transitions: `forward`, `back`, `root`, `tab`, `zoom`, `none`. |
| `beginZoomTransition(el, opts?)` / `finishZoomTransition(el?, opts?)` | Helpers that measure a DOM element for `zoom`. |
| `getPluginVersion()` | Native version marker (`'web'` on web). |
| `defineNativeNavigationElements()` | Registers `<cap-native-navigation-provider>`, `<cap-native-navbar>`, `<cap-native-tabbar>`. |

Events: `navbarBack`, `navbarItemTap`, `navbarSearch`, `navbarSegmentSelect`, `tabSelect`, `safeAreaChanged`, `verticalBarChanged`, `hingeChanged`, `transitionStart`, `transitionEnd`, `pullToRefresh`.

## References

Only load a reference when its topic is in play.

| File | Load when |
|------|-----------|
| [references/api.md](references/api.md) | Calling any method, listening to any event, using zoom helpers or web components |
| [references/options.md](references/options.md) | Building navbar / tabbar / configure / icon / color / glass / transition options, or looking up a type alias |
| [references/platform-behavior.md](references/platform-behavior.md) | Insets and CSS variables, iOS vs Android vs web differences, Liquid Glass, overlays, scroll behavior, iPhone Duo, debugging layout |

## Patterns

### Navbar buttons and back

```typescript
await NativeNavigation.setNavbar({
  title: 'Inbox',
  backButton: { visible: true, title: 'Mailboxes' },
  rightItems: [{ id: 'compose', accessibilityLabel: 'Compose', icon: { ios: { sfSymbol: 'square.and.pencil' } } }],
});
NativeNavigation.addListener('navbarItemTap', ({ id, placement }) => {
  if (id === 'compose') router.push('/compose');
});
```

### Push with a native snapshot transition

```typescript
const t = await NativeNavigation.beginTransition({ direction: 'forward' });
try {
  await router.push('/detail');
  await NativeNavigation.setNavbar({ title: 'Detail', backButton: { visible: true, title: 'Back' } });
} finally {
  await NativeNavigation.finishTransition({ id: t.id, direction: 'forward' });
}
```

With `@capgo/capacitor-transitions` animating the WebView page stack, skip `beginTransition` for that navigation: pick one animation layer per navigation. Use the plugin's zoom helpers only for shared-element routes.

### Overlay open/close

Hide bars before an overlay presents and restore the same options after it dismisses. Count stacked overlays.

```typescript
await NativeNavigation.setNavbar({ ...navbar, hidden: true });
await NativeNavigation.setTabbar({ ...tabbar, hidden: true, animated: true });
// after dismiss
await NativeNavigation.setNavbar({ ...navbar, hidden: false });
await NativeNavigation.setTabbar({ ...tabbar, hidden: false, animated: true });
```

### Pull to refresh

```typescript
await NativeNavigation.setPullToRefresh({ enabled: true });
NativeNavigation.addListener('pullToRefresh', async () => {
  try {
    await reloadData();
  } catch (err) {
    showError(err);                       // e.g. offline; tell the user
  } finally {
    await NativeNavigation.endPullToRefresh(); // spinner stays until this runs
  }
});
```

Search, segment rows, scroll-driven chrome, tab styling and Duo patterns: [references/api.md](references/api.md) and [references/platform-behavior.md](references/platform-behavior.md).

## Traps

1. **Double safe-area padding.** The `--cap-native-navigation-*` values already include the status bar and home indicator. Never write `calc(env(safe-area-inset-top) + var(--cap-native-navigation-top))`. When a bar can be hidden, use `max(env(safe-area-inset-top), var(--cap-native-navigation-top))`. Remove `padding: env(safe-area-inset-*)` on a wrapper that also gets the plugin variables. On iOS 26+ do not add `--cap-native-system-tabbar-height` to bottom padding: the hosted WebView already ends above the bar.
2. **Router and tab selection drift.** Native taps move the selection immediately; the next `setTabbar` re-applies `selectedId`. Update `selectedId` on every route change (deep links, `router.back()`, programmatic navigation), not only in `tabSelect`. Same for `segments[].selectedId` and `search.text`.
3. **Partial updates wipe state.** Sending `{ hidden: true }` alone clears tabs / title on native. Always spread the last full options.
4. **Android hardware back is not `navbarBack`.** `navbarBack` fires only when the user taps the native back control (iOS and Android). Handle the Android system back button / gesture yourself, for example with `@capacitor/app` `App.addListener('backButton', ...)`, and route both to the same back function.
5. **Transition left open.** After `beginTransition`, the live WebView is nearly transparent until `finishTransition`. Always finish in `finally`, and never stack a web page transition on the same navigation.
6. **Overlays under the bars.** `ion-modal`, `<dialog>` and menus are inside the WebView; hide the bars they cover, then restore with full options. `animated: false` on the iOS 26 system tab bar tears the tab controller down; prefer `animated: true` for overlay toggles.
7. **Icons must be serializable.** No framework components. Use `svg` (path, line, polyline, polygon, circle, rect only), SF Symbols, asset-catalog images, or Android drawable names. Set `accessibilityLabel` on icon-only buttons.
8. **Colors on iOS 26+.** `colors.background` is ignored and `inactiveTint` needs `experimentalBakedTintColors` (which can shift badges/icon size). Let Liquid Glass be.
9. **Android blur.** `liquidGlass` on Android is a translucent tint only. Put a CSS `backdrop-filter` element under the bar (or use `edgeBlur`) when blur is wanted.
10. **Scroll roots.** Scroll hide, tab minimize and pull-to-refresh only see `window`, `#app` and `[data-cap-native-navigation-scroll]`. Mark the real scroll container or call `reportNavbarScroll()` for others, never both.
11. **Web lies.** Web merges options, keeps a previous `search`, and does nothing for pull-to-refresh. Verify on devices.

## Verify on Device

1. `npx cap sync` then run on an iOS 26+ simulator/device and an Android 12+ device; also iOS 18 or older if supported (non-Liquid Glass path).
2. Check: first and last list rows clear both bars; no extra gap under the status bar; rotation and iPad split view keep correct insets (`safeAreaChanged`).
3. Tap every tab, deep link into a nested route, go back with the native back button and (Android) the system back gesture: selected tab and title must match the route each time.
4. Open and close each modal/sheet: bars hide and come back with the same tabs and selection.
5. Run a push and back transition rapidly; the page must never stay blank.
6. Inspect variables in Safari Web Inspector / Chrome DevTools: `getComputedStyle(document.documentElement).getPropertyValue('--cap-native-navigation-top')`.
7. `await NativeNavigation.getPluginVersion()` confirms the native side is installed (returns `'web'` in a browser).

## Resources

- Docs: https://capgo.app/docs/plugins/native-navigation/
- Source and example app: https://github.com/Cap-go/capacitor-native-navigation (`example-app/`)
- npm: https://www.npmjs.com/package/@capgo/capacitor-native-navigation

Files in this skill

  • SKILL.md14.4 KB
  • references/api.md11.1 KB
  • references/options.md13.3 KB
  • references/platform-behavior.md9.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.