Skip to content

TabBar ​

17:06

Description ​

A bottom navigation bar. Configure each item's icon, text, badge and raised button (midButton) via list, with v-model binding the active index by default. When an item sets pagePath, taps navigate with uni.switchTab, the active state is derived from the current page route (getCurrentPages) and v-model no longer participates; use beforeSwitch to intercept a switch.

Compatibility ​

PlatformSupport
App✅ Supported (gap has no effect; icon–text spacing is fixed)
H5✅ Supported
WeChat Mini Program✅ Supported

Examples ​

Select Demo Scene ​

The bottom tab bar is fixed at the bottom of the screen; switch scenes below to view different configurations.

Example 2 ​

API ​

Props ​

PropertyDescriptionTypeDefaultVersion
showWhether to displaybooleantrue-
modelValuev-model bound valuenumber0-
bgColorBackground colorstring''-
heightHeightstring'50px'-
iconSizeIcon sizestringDEFAULT_ICON_SIZE-
midButtonSizeCenter raised-button sizestringDEFAULT_MID_BUTTON_SIZE-
activeColorActive colorstring''-
inactiveColorInactive colorstring''-
midButtonWhether to show the center raised buttonbooleanfalse-
listTab listTabbarItem[]--
zIndexz-indexstring''-
beforeSwitchCallback before switching(index: number) => boolean | Promise<boolean>--
borderTopWhether to show the top borderbooleantrue-
hideTabBarWhether to hide the native tab barbooleantrue-
gapSpacing between icon and textstring'2px'-
textSizeText sizestringDEFAULT_TEXT_SIZE-
customClassCustom class namestring''-
customStyleCustom stylestring''-

Events ​

EventDescriptionParamsVersion
changeFires when a tab is tapped; the callback is the tapped tab indexindex: number-

Slots ​

ux-tabbar has no slots.

Notes ​

  • hide-tab-bar defaults to true and calls uni.hideTabBar() on mount; on a non-tabBar page (such as the demo page) this throws hideTabBar:fail not TabBar page — pass hide-tab-bar="false" explicitly.
  • When an item sets pagePath, taps navigate with uni.switchTab and the active state is derived from the current page route (getCurrentPages); v-model and change no longer drive that item. Only items without pagePath are tracked by v-model.
  • beforeSwitch returning false (or a Promise resolving false) blocks the switch.
  • The raised button requires both the global mid-button and that item's midButton: true.
  • gap only takes effect on H5 / WeChat Mini Program; on App the icon–text spacing is fixed.