Taro.setTabBarStyle(option)
Dynamically sets the overall style of the tabBar.
Type
(option?: Option) => Promise<CallbackResult>
Parameters
Option
| Property | Type | Required | Description |
|---|---|---|---|
| backgroundColor | string | No | The background color of tab, HexColor |
| borderStyle | string | No | The border color of tabBar, which only supports black/white |
| color | string | NO | The default color of text on tab, HexColor |
| selectedColor | string | No | The color of the selected text on tab, HexColor |
| 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
Taro.setTabBarStyle({
color: '#FF0000',
selectedColor: '#00FF00',
backgroundColor: '#0000FF',
borderStyle: 'white'
})
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| Taro.setTabBarStyle | ✔️ | ✔️ | ✔️ |