---
name: "setTabBarItem"
mode: "kit"
versionRequirements:
  - { name: "MiniKit", version: "1.0.0" }
platform:
  - "iOS"
  - "Android"
async: true
---

## setTabBarItem

> [VERSION] MiniKit >= 1.0.0

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Dynamically set the content of a tabBar item

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `index` | `number` | Yes | - | `1.0.0` | Index of the tabBar item, counting from the left |
| `text` | `string` | Yes | - | `1.0.0` | Button text on the tab |
| `iconPath` | `string` | Yes | - | `1.0.0` | Image path |
| `selectedIconPath` | `string` | Yes | - | `1.0.0` | Image path when selected |
| `complete` | `() => void` | No | - | - | Completion callback (invoked on both success and failure) |
| `success` | `() => void` | No | - | - | Success callback |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Extended error |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Extended error code |
| `errorMsg` | `string` | Extended error information |


### Examples

```tsx
ty.setTabBarItem({
  index: 0,
  text: "Home",
  iconPath: "/assets/tab_home.png",
  selectedIconPath: "/assets/tab_home_selected.png",
  success: data => { console.log(data); },
  fail: error => { console.error(error); },
});
```
