---
name: "showToast"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.0.1" }
platform:
  - "iOS"
  - "Android"
async: true
---

## showToast

> [VERSION] BaseKit >= 2.0.1

> [PLATFORM] iOS, Android

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

### Description

Show a message toast

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `title` | `string` | Yes | - | `2.0.1` | Message content |
| `icon` | `string` | No | `"success"` | `2.0.1` | Icon: 'success' / 'error' / 'loading' / 'none' |
| `image` | `string` | No | - | `2.0.1` | Local path to a custom icon; image takes precedence over icon |
| `duration` | `number` | No | `1500` | `2.0.1` | Display delay (iOS only) |
| `mask` | `boolean` | No | `false` | `2.0.1` | Whether to show a transparent overlay to prevent touch-through |
| `complete` | `() => void` | No | - | - | Callback when the API call completes (runs on 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` | Error extension |

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

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


### Examples

```tsx
// Show a toast message
ty.showToast({
  title: "Success",
  icon: "success",
  duration: 1500,
  mask: false,
  success: () => console.log("toast displayed"),
  fail: error => console.error(error),
});
```
