Skip to main content
Version: v3

createModal

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

createModal_image}

Create Modal prompt box.

Type

function createModal(option: Option): Modal

Parameters

Option

PropertyTypeRequiredDefaultValueDescriptionAPI_LEVEL
contentstringY-title of Modal2.0
titlestringN-Modal dialog box title, alias for content3.6
showbooleanNfalseWhether to display Modal immediately after the creation is completed2.0
onClick(keyObj: KeyObj) => voidN-Whether to display Modal immediately2.0
autoHidebooleanNtrueWhether to automatically close the Modal dialog after clicking the Confirm or Cancel button2.0
subtitlestringN-subtitle3.6
srcstringN-Icon icon path3.6
textstringN-text content3.6
textColornumberN0xFFFFFFtext color3.6
textAlphanumberN255Text transparency, transparency [0-255], 0 is full transparency3.6
okButtonstringN-The icon path of the confirmation button3.6
cancelButtonstringN-Cancel button icon icon path3.6
capsuleButtonArray<string>N-Capsule button configuration, as a string array, click type in the returned KeyObj starting from 103.6

KeyObj

PropertyTypeDescriptionAPI_LEVEL
typenumberModal key name, value reference Modal key name constants2.0
PropertyTypeDescriptionAPI_LEVEL
show(isShow: boolean) => voidShow or hide Modal2.0

Constants

ConstantDescriptionAPI_LEVEL
MODAL_CONFIRMModal Confirm button2.0
MODAL_CANCELModal Cancel button2.0

Example

import { createModal, MODAL_CONFIRM } from '@zos/interaction'

const dialog = createModal({
content: 'hello world',
autoHide: false,
onClick: (keyObj) => {
const { type } = keyObj
if (type === MODAL_CONFIRM) {
console.log('confirm')
} else {
dialog.show(false)
}
},
})

dialog.show(true)