@capawesome/capacitor-tab-bar

中文文档
0.1.0发布于 2026/10/01MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2438

Capacitor plugin to display a native tab bar with Liquid Glass on iOS.

原始使用文档
文档目录26 节
  1. Features
  2. Compatibility
  3. Installation
  4. iOS
  5. Configuration
  6. Examples
  7. Demo
  8. Usage
  9. Set the tabs and show the tab bar
  10. Listen for tab selections
  11. Select a tab programmatically
  12. Update a badge
  13. Customize the colors
  14. Ionic Framework
  15. API
  16. hide()
  17. selectTabById(...)
  18. setColors(...)
  19. setTabs(...)
  20. show()
  21. addListener('tabSelected', ...)
  22. removeAllListeners()
  23. Interfaces
  24. Newsletter
  25. Changelog
  26. License

Capacitor Tab Bar Plugin

Capacitor plugin to display a native tab bar with Liquid Glass on iOS.

Features

  • 🫧 Liquid Glass: Renders the native Liquid Glass tab bar on iOS 26 and the classic tab bar on earlier versions.
  • 🧭 Tabs: Use SF Symbols or images from your asset catalog as icons and show badges.
  • 🎨 Colors: Customize the colors of the selected and unselected tabs.
  • 📐 Safe area: Extends the bottom safe area inset of the web view, so your content is never covered by the tab bar.
  • 🚀 Launch configuration: Show the tab bar from launch without waiting for your web app.
  • 📦 CocoaPods & SPM: Supports CocoaPods and Swift Package Manager for iOS.
  • 🔁 Up-to-date: Always supports the latest Capacitor version.

Missing a feature? Just open an issue and we'll take a look!

Compatibility

Plugin VersionCapacitor VersionStatus
0.x.x>=8.x.xActive support

Installation

You can use our AI-Assisted Setup to install the plugin. Add the Capawesome Skills to your AI tool using the following command:

npx skills add capawesome-team/skills --skill capacitor-plugins

Then use the following prompt:

 Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-tab-bar` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capawesome/capacitor-tab-bar
npx cap sync

This plugin is only available on iOS. On Android and Web, all methods reject as unimplemented.

iOS

The tab bar is placed on top of the web view and the bottom safe area inset of the web view is increased by the height of the tab bar. Your web app must meet the following requirements so that its content is not covered by the tab bar:

  • The viewport meta tag of your page must contain viewport-fit=cover:

    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
    
  • The ios.contentInset configuration option must be set to never (default). With always, the inset is applied twice.

  • Your content must respect the bottom safe area inset, for example using padding-bottom: env(safe-area-inset-bottom).

If you use @capacitor/splash-screen, do not configure the tabs in your Capacitor configuration, as the tab bar would be displayed on top of the splash screen. Instead, call setTabs(...) and show() after SplashScreen.hide().

Configuration

These configuration values are available:

PropTypeDescriptionSince
tabsTab[]The tabs to display at launch. If set, the tab bar is created and visible from launch. Do not set this option if you use @capacitor/splash-screen, as the tab bar would be displayed on top of the splash screen. Only available on iOS.0.1.0
selectedTabIdstringThe ID of the tab to select at launch. If not set, the first tab is selected. Only available on iOS.0.1.0
selectedColorstringThe color of the selected tab as a hex color code. If not set, the system default is used. Only available on iOS.0.1.0
unselectedColorstringThe color of the unselected tabs as a hex color code. If not set, the system default is used. Has no effect on iOS 26 and later, as the system determines the color of the unselected tabs on Liquid Glass. Only available on iOS.0.1.0

Examples

In capacitor.config.json:

{
  "plugins": {
    "TabBar": {
      "tabs": [{ "id": "home", "title": "Home", "systemImage": "house.fill" }],
      "selectedTabId": "home",
      "selectedColor": "#007AFF",
      "unselectedColor": "#8E8E93"
    }
  }
}

In capacitor.config.ts:

/// <reference types="@capawesome/capacitor-tab-bar" />

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    TabBar: {
      tabs: [{ "id": "home", "title": "Home", "systemImage": "house.fill" }],
      selectedTabId: "home",
      selectedColor: "#007AFF",
      unselectedColor: "#8E8E93",
    },
  },
};

export default config;

Demo

iOS
iOS Demo

Usage

The following examples show how to set up the tab bar and react to tab selections.

Set the tabs and show the tab bar

Set the tabs and show the tab bar. Each tab uses either an SF Symbol (systemImage) or an image from the asset catalog of your app (image) as its icon. Only available on iOS:

import { TabBar } from '@capawesome/capacitor-tab-bar';

const showTabBar = async () => {
  await TabBar.setTabs({
    tabs: [
      { id: 'home', title: 'Home', systemImage: 'house.fill' },
      { id: 'search', title: 'Search', systemImage: 'magnifyingglass' },
      { id: 'inbox', title: 'Inbox', systemImage: 'tray.fill', badge: '3' },
      { id: 'profile', title: 'Profile', image: 'profile-icon' },
    ],
    selectedTabId: 'home',
  });
  await TabBar.show();
};

const hideTabBar = async () => {
  await TabBar.hide();
};

Alternatively, configure the tabs in your Capacitor configuration to show the tab bar from launch (see Configuration).

Listen for tab selections

The tabSelected event is emitted every time the user taps a tab, including the tab that is already selected. Only available on iOS:

import { TabBar } from '@capawesome/capacitor-tab-bar';

const addListener = async () => {
  await TabBar.addListener('tabSelected', event => {
    console.log('Tab selected:', event.id);
  });
};

Select a tab programmatically

Select a tab, for example after navigating within your web app. This method does not emit the tabSelected event. Only available on iOS:

import { TabBar } from '@capawesome/capacitor-tab-bar';

const selectTab = async () => {
  await TabBar.selectTabById({ id: 'search' });
};

Update a badge

Call setTabs(...) again with the updated tabs. The currently selected tab stays selected. Only available on iOS:

import { TabBar } from '@capawesome/capacitor-tab-bar';

const updateBadge = async () => {
  await TabBar.setTabs({
    tabs: [
      { id: 'home', title: 'Home', systemImage: 'house.fill' },
      { id: 'search', title: 'Search', systemImage: 'magnifyingglass' },
      { id: 'inbox', title: 'Inbox', systemImage: 'tray.fill', badge: '4' },
      { id: 'profile', title: 'Profile', image: 'profile-icon' },
    ],
  });
};

Customize the colors

Set the colors of the selected and unselected tabs. Colors that are not provided are reset to the system default. On iOS 26 and later, the unselected color has no effect, as the system determines the color of the unselected tabs on Liquid Glass. Only available on iOS:

import { TabBar } from '@capawesome/capacitor-tab-bar';

const setColors = async () => {
  await TabBar.setColors({
    selectedColor: '#FF2D55',
    unselectedColor: '#8E8E93',
  });
};

Ionic Framework

If you use Ionic Framework, you can replace the ion-tab-bar with the native tab bar on iOS and keep using the Ionic router for navigation:

  1. Hide the ion-tab-bar on iOS:

    .plt-ios ion-tab-bar {
      display: none;
    }
    
  2. Navigate to the tapped tab using the router and select the native tab whenever the route changes to another tab. Use the same IDs for the native tabs as for the tab property of your ion-tab-button elements. The following example uses Angular, but the same approach works with React and Vue:

    <ion-tabs (ionTabsDidChange)="handleTabsDidChange($event)">
      <!-- ... -->
    </ion-tabs>
    
    import { Component, OnInit } from '@angular/core';
    import { Router } from '@angular/router';
    import { Capacitor } from '@capacitor/core';
    import { TabBar } from '@capawesome/capacitor-tab-bar';
    
    @Component({
      selector: 'app-tabs',
      templateUrl: 'tabs.page.html',
    })
    export class TabsPage implements OnInit {
      private readonly isIos = Capacitor.getPlatform() === 'ios';
    
      constructor(private readonly router: Router) {}
    
      ngOnInit() {
        if (this.isIos) {
          void TabBar.addListener('tabSelected', ({ id }) => {
            void this.router.navigateByUrl(`/tabs/${id}`);
          });
        }
      }
    
      handleTabsDidChange(event: { tab: string }) {
        if (this.isIos) {
          void TabBar.selectTabById({ id: event.tab });
        }
      }
    }
    
  3. Pad your content with the bottom safe area inset, which includes the height of the native tab bar:

    ion-content {
      --padding-bottom: env(safe-area-inset-bottom);
    }
    

API

hide()

hide() => Promise<void>

Hide the tab bar.

The tabs are kept and the bottom safe area inset is reset.

Only available on iOS.

Since: 0.1.0


selectTabById(...)

selectTabById(options: SelectTabByIdOptions) => Promise<void>

Select the tab with the given ID.

This method does not emit the tabSelected event.

Only available on iOS.

ParamType
optionsSelectTabByIdOptions

Since: 0.1.0


setColors(...)

setColors(options: SetColorsOptions) => Promise<void>

Set the colors of the tabs.

Colors that are not provided are reset to the system default.

Only available on iOS.

ParamType
optionsSetColorsOptions

Since: 0.1.0


setTabs(...)

setTabs(options: SetTabsOptions) => Promise<void>

Set the tabs of the tab bar.

This replaces all existing tabs. The tab with the ID selectedTabId is selected if provided. Otherwise, the currently selected tab stays selected if its ID still exists, or the first tab is selected.

This method does not change the visibility of the tab bar.

Only available on iOS.

ParamType
optionsSetTabsOptions

Since: 0.1.0


show()

show() => Promise<void>

Show the tab bar.

The tab bar is placed at the bottom of the screen and the bottom safe area inset of the web view is increased by the height of the tab bar.

The tabs must be set first using setTabs(...) or the tabs configuration.

Only available on iOS.

Since: 0.1.0


addListener('tabSelected', ...)

addListener(eventName: 'tabSelected', listenerFunc: (event: TabSelectedEvent) => void) => Promise<PluginListenerHandle>

Called when the user taps a tab.

This event is also emitted if the user taps the tab that is already selected.

Only available on iOS.

ParamType
eventName'tabSelected'
listenerFunc(event: TabSelectedEvent) => void

Returns: Promise<PluginListenerHandle>

Since: 0.1.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Only available on iOS.

Since: 0.1.0


Interfaces

SelectTabByIdOptions

PropTypeDescriptionSince
idstringThe ID of the tab to select.0.1.0

SetColorsOptions

PropTypeDescriptionSince
selectedColorstringThe color of the selected tab as a hex color code. If not provided, the system default is used.0.1.0
unselectedColorstringThe color of the unselected tabs as a hex color code. If not provided, the system default is used. Has no effect on iOS 26 and later, as the system determines the color of the unselected tabs on Liquid Glass.0.1.0

SetTabsOptions

PropTypeDescriptionSince
tabsTab[]The tabs to display. Each tab must have a unique ID.0.1.0
selectedTabIdstringThe ID of the tab to select. If not provided, the currently selected tab stays selected if its ID still exists. Otherwise, the first tab is selected.0.1.0

Tab

PropTypeDescriptionSince
idstringThe unique ID of the tab.0.1.0
titlestringThe title of the tab.0.1.0
systemImagestringThe name of an SF Symbol to use as the icon of the tab. Exactly one of systemImage or image must be provided.0.1.0
imagestringThe name of an image in the asset catalog of the app to use as the icon of the tab. The image is rendered as a template image. Exactly one of systemImage or image must be provided.0.1.0
badgestringThe badge value of the tab. If not provided, no badge is shown.0.1.0

PluginListenerHandle

PropType
remove() => Promise<void>

TabSelectedEvent

PropTypeDescriptionSince
idstringThe ID of the tab that was tapped.0.1.0

Newsletter

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our Capawesome Newsletter.

Changelog

See CHANGELOG.md.

License

See LICENSE.

版本与发布记录

@capawesome/capacitor-tab-bar 共发布 2 个版本,首次发布于 2026/10/01;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.0latest2026/10/011 个月前
0.0.12026/10/011 个月前

关于 @capawesome/capacitor-tab-bar 的常见问题

@capawesome/capacitor-tab-bar 是什么?

Capacitor plugin to display a native tab bar with Liquid Glass on iOS.

如何安装 @capawesome/capacitor-tab-bar?

在项目目录运行 npm install @capawesome/capacitor-tab-bar,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capawesome/capacitor-tab-bar 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capawesome/capacitor-tab-bar 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capawesome/capacitor-tab-bar 可以商用吗?

@capawesome/capacitor-tab-bar 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capawesome/capacitor-tab-bar 的下载量有多少?

根据 npm 官方下载统计,@capawesome/capacitor-tab-bar 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,438 次,日均约 81 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capawesome/capacitor-tab-bar 还在维护吗?

最新版本 0.1.0 发布于 2026/10/01(1 个月前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/10/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。