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

## showModal

> [VERSION] BaseKit >= 2.0.1

> [PLATFORM] iOS, Android

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

### Description

Show a modal dialog

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `title` | `string` | Yes | - | `2.0.1` | Title |
| `content` | `string` | No | - | `2.0.1` | Content |
| `showCancel` | `boolean` | No | `true` | `2.0.1` | Whether to show a Cancel button |
| `cancelText` | `string` | No | `"cancel"` | `2.0.1` | Text for the Cancel button, up to 4 characters |
| `cancelColor` | `string` | No | - | `2.0.1` | Cancel button text color, must be a hex color string |
| `confirmText` | `string` | No | `"confirm"` | `2.0.1` | Text for the Confirm button, up to 4 characters |
| `confirmColor` | `string` | No | - | `2.0.1` | Confirm button text color, must be a hex color string |
| `isShowGlobal` | `boolean` | No | `false` | `3.14.3` | Whether to show as a global dialog; if global, it appears on top |
| `modalStyle` | `0 \| 1` | No | `0` | `3.21.2` | Dialog style |
| `inputAttr` | `InputBean` | No | - | `3.21.2` | Input field properties for the dialog |
| `complete` | `() => void` | No | - | - | Callback when the API call completes (runs on success and failure) |
| `success` | `(params: Object) => void` ↓see below | No | - | - | Success callback |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### success callback parameters

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `confirm` | `boolean` | `3.2.6` | true if the user tapped Confirm |
| `cancel` | `boolean` | `3.2.6` | true if the user tapped Cancel (used on Android to distinguish dismiss via overlay from tapping Cancel) |
| `inputContent` | `string` | `3.21.2` | Input value |

#### 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 |


### Referenced Types

##### `interface` InputBean

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `placeholder` | `string` | `3.21.2` | Input placeholder text |
| `placeHolderColor` | `string` | `3.21.2` | Input placeholder text color |
| `backgroundColor` | `string` | `3.21.2` | Input background color, default is white |
| `textColor` | `string` | `3.21.2` | Input text color |


### Valid Values

##### `modalStyle` valid values

| Value | Description |
| --- | --- |
| `0` | Default style |
| `1` | Input style |


### Examples

```tsx
// Show a modal dialog; callback indicates whether the user tapped Confirm or Cancel
ty.showModal({
  title: "Prompt",
  content: "Are you sure you want to proceed?",
  showCancel: true,
  cancelText: "Cancel",
  confirmText: "Confirm",
  success: data => console.log("confirm:", data.confirm, "cancel:", data.cancel),
  fail: error => console.error(error),
});
```
