# Pop-up Window >![](../../public_sys-resources/icon-note.gif) **NOTE:** >The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Module to Import ``` import prompt from '@system.prompt'; ``` ## Required Permissions None ## prompt.showToast showToast\(Object\): void Displays the toast dialog box. - Parameter

Name

Type

Mandatory

Description

message

string

Yes

Text to display.

duration

number

No

Duration of the toast dialog box. The default value is 1500. The recommended value ranges from 1500 ms to 10000 ms.

NOTE:

A value less than 1500 is automatically changed to 1500. The maximum value is 10000 ms.

[bottom]5+

<length>

No

Distance between the dialog border and the bottom of the screen.

NOTE:

This parameter is only supported on phones and tablets.

- Example ``` export default { showToast() { prompt.showToast({ message: 'Message Info', duration: 2000, }); } } ``` ## prompt.showDialog showDialog\(\): void Displays the dialog box. - Parameter

Name

Type

Mandatory

Description

title

string

No

Title of the text to display.

message

string

No

Text body.

buttons

Array

No

Array of buttons in the dialog box. The array structure is {text:'button', color: '#666666'}. One to three buttons are supported. The first button is of the positiveButton type, the second is of the negativeButton type, and the third is of the neutralButton type.

success

Function

No

Called when the dialog box is displayed. For the return value, see return values of the success callback.

cancel

Function

No

Called when the operation is cancelled.

complete

Function

No

Called when the dialog box is closed.

Return values of the **success** callback

Parameter

Type

Description

index

number

Index of the selected button in the buttons array

- Example ``` export default { showDialog() { prompt.showDialog({ title: 'Title Info', message: 'Message Info', buttons: [ { text: 'button', color: '#666666', }, ], success: function(data) { console.log('dialog success callback,click button : ' + data.index); }, cancel: function() { console.log('dialog cancel callback'); }, }); } } ``` ## prompt.showActionMenu6+ showActionMenu\(Object\): void Displays the operation menu. - Parameters

Name

Type

Mandatory

Description

title

string

No

Title of the text to display.

buttons

Array

Yes

Array of buttons in the dialog box. The array structure is {text:'button', color: '#666666'}. One to six buttons are supported. If there are more than six buttons, the pop-up window will not be displayed.

success

(data: TapIndex) => void

No

Called when the operation is successful.

cancel

() => void

No

Called when the operation fails.

complete

() => void

No

Called when the operation is complete.

**Table 1** TapIndex

Name

Type

Description

tapIndex

number

Index of the selected button in the buttons array, starting from 0.

- Example ``` export default { showActionMenu() { prompt.showActionMenu({ title: 'Title Info', buttons: [ { text: 'item1', color: '#666666', }, { text: 'item2', color: '#000000', }, ], success: function(data) { console.log('Operation succeeded. Click button: ' + data.tapIndex); }, fail: function(data) { console.log('Operation failed' + data.errMsg); }, }); } } ```