Skip to main content
Version: v3.x

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-Content of Modal2.0
showbooleanNfalseWhether to display Modal immediately after the creation is completed2.0
onClick(keyName: ModalKey) => voidN-Whether to display Modal immediately2.0
autoHidebooleanNtrueWhether to automatically close the Modal dialog after clicking the Confirm or Cancel button2.0

ModalKey

TypeDescription
numberModal key name, value reference Modal key name constants
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: (keyName) => {
if (keyName === MODAL_CONFIRM) {
console.log('confirm')
} else {
dialog.show(false)
}
},
})

dialog.show(true)