title: Taro.setTabBarItem(option)

sidebar_label: setTabBarItem

Dynamically sets the content of a tabBarn item. For image content, temporary files and network files are supported as of 2.7.0.

Reference

Type

  1. (option: Option) => Promise<CallbackResult>

Parameters

Option

Property Type Required Description
index number Yes Specifies which item of tabBar, starting from the left
text string No The text of a button on tab
iconPath string No The path to the icon. The icon size is limited to 40 KB. Recommended size is 81 px 81 px, This parameter does not take effect when postion is top.
selectedIconPath string No The path to the selected icon. The icon size is limited to 40 KB. Recommended size is 81 px 81 px, This parameter does not take effect when postion is top.
complete (res: CallbackResult) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
fail (res: CallbackResult) => void No The callback function for a failed API call
success (res: CallbackResult) => void No The callback function for a successful API call

Sample Code

  1. Taro.setTabBarItem({
  2. index: 0,
  3. text: 'text',
  4. iconPath: '/path/to/iconPath',
  5. selectedIconPath: '/path/to/selectedIconPath'
  6. })

API Support

API WeChat Mini-Program H5 React Native
Taro.setTabBarItem ✔️ ✔️ ✔️