# 	addTabBarItem(Object object)

Adds an item to the tab bar (on the bottom of a gadget)

## Support

App capability | Android | iOS | PC | Harmony | Preview
---|---|---|---|---|---
Gadget | V5.1.0+ | V5.1.0+ | V5.1.0+ | V7.35.0+ | Preview
Web app | **X** | **X** | **X** | **X** | /

## Input

Inherits [standard object input](https://open.feishu.cn/document/uYjL24iN/ukzNy4SO3IjL5cjM), and has the following extension properties:

Name | Data type | Required | Default value | Description
---|---|---|---|---
index | number | Yes | &nbsp; | Tab index<br>**Example value**: 0, 1, 2
pagePath | string | Yes | &nbsp; | Tab path<br>**Example value**: 'pages/index/index'
text | string | Yes | &nbsp; | Text displayed on the tab, which can be "" but can't be `null`
light | object[] | Yes | &nbsp; | Light mode data
&emsp;<br>∟<br>&nbsp;<br>iconPath | string | Yes | &nbsp; | Image not selected for the light mode tab, including its CDN address and locally packaged image resources
&emsp;<br>∟<br>&nbsp;<br>selectedIconPath | string | Yes | &nbsp; | Image selected for the light mode tab, including its CDN address and locally packaged image resources
dark | object[] | Yes | &nbsp; | Dark mode data
&emsp;<br>∟<br>&nbsp;<br>iconPath | string | Yes | &nbsp; | Image not selected for the dark mode tab, including its CDN address and locally packaged image resources
&emsp;<br>∟<br>&nbsp;<br>selectedIconPath | string | Yes | &nbsp; | Image selected for the dark mode tab, including its CDN address and locally packaged image resources

## Output

Inherits [standard object output](https://open.feishu.cn/document/uYjL24iN/ukzNy4SO3IjL5cjM#8c92acb8), without extension property

## Sample code

```js
tt.addTabBarItem({
    index: 1, 
    pagePath:"pages/index/index", 
    text: "text", 
    light: {
      iconPath: "xx", 
      selectedIconPath: "xx" 
    },
    dark: {
      iconPath: "xx", 
      selectedIconPath: "xx" 
    },
    success(res) {
      console.log(JSON.stringify(res));
    },
    fail(res) {
      console.log(`addTabBarItem fail: ${JSON.stringify(res)}`);
    }
});
```

Sample return object for `success`:
```json
{
	"errMsg":"addTabBarItem:ok"
}
```

## Error code
If a `fail` object is returned, an [errCode property](https://open.feishu.cn/document/uYjL24iN/ukzNy4SO3IjL5cjM#a825f4c8) that indicates the error code will be contained. For error codes, refer to the following table.

Error code | Error message | Description
--|--|--|--|--
| `-10001` | fatal error: no request  | Model in the API service is empty |
| `-10002` | no page path | Page path in the API service is empty                |
| `-10003 `| no page text                                | Page text is empty           |
| `-10004 `| no page lightIcon                           | Light icon model is empty        |
| `-10005` | no page lightIcon iconPath                  | Light icon path is empty          |
| `-10006` | no page lightIcon selectedIconPath          | Light selectedIconPath is empty |
| `-10007` | no page darkIcon                            | Dark icon model is empty         |
| `-10008` | no page darkIcon iconPath                   | Dark icon path is empty           |
| `-10009` | no page darkIcon selectedIconPath           | Dark selectedIconPath is empty  |
| `-10010` | at most 5 tabs should be remained           |       Unable to add more tabs as up to 5 tabs can be added                    |
| `-10011` | index is invalid                            | Invalid index (negative or greater than the number of existing tabs)   |
| `-10012` | this tab already exists                     | pagePath already exists                      |
| `-10013` | no tab                                      | Unable to add items in case of no tab                           |
| `-20001` | no current tab controller                   | Tab fragment is empty                          |
| `-20002` | no current app view proxy                   | Tab fragment activity is empty                 |
|` -20003` | only support in gadget                      | Not a gadget form |
| `-20004` | no tab host                                 | Tab host initiation error |                          
| `-20005` | add target tab fail, cannot find target tab | An error occurred when adding tabwidget |

## Known issues

- After using this api to add a button on iOS side before [V5.15.0](https://open.feishu.cn/document/uYjL24iN/uAjMuAjMuAjM/version-compatibility), the style of the title is not synchronized with the tabBar configuration in app.json. You can use [setTabBarStyle](https://open.feishu.cn/document/uYjL24iN/uITN04iM1QjLyUDN) in the success callback to reset the tabBar style.