Skip to main content
Version: Next

Taro.setTabBarItem(option)

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

(option: Option) => Promise<CallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
indexnumberYesSpecifies which item of tabBar, starting from the left
textstringNoThe text of a button on tab
iconPathstringNoThe 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.
selectedIconPathstringNoThe 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) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: CallbackResult) => voidNoThe callback function for a failed API call
success(res: CallbackResult) => voidNoThe callback function for a successful API call

Sample Code

Taro.setTabBarItem({
index: 0,
text: 'text',
iconPath: '/path/to/iconPath',
selectedIconPath: '/path/to/selectedIconPath'
})

API Support

APIWeChat Mini-ProgramH5React Native
Taro.setTabBarItem✔️✔️✔️