Open menu dropdown
useDialog
Open a confirmation or information dialog from your script and await the answer of the user (confirm or cancel), with customizable buttons - through the dialog plugin, instead of window.confirm.
WARNING
You must install dialog plugin before use it
TIP
More info about dialog plugin in its documentation
Usage
vue
<script lang="ts" setup>
import { useDialog } from 'maz-ui/composables/useDialog'
import { useToast } from 'maz-ui/composables/useToast'
const dialog = useDialog()
const toast = useToast()
function openDialog() {
dialog.open({
title: 'Dialog title',
message: 'Dialog message',
onAccept: (response) => {
toast.success(`Dialog accepted`, {
position: 'bottom',
})
},
onReject: (response) => {
toast.error(`Dialog rejected`, {
position: 'bottom',
})
},
})
}
</script>
<template>
<MazBtn @click="openDialog">
Open Dialog
</MazBtn>
</template>Await the choice
confirm returns a Promise<boolean> resolved with true on accept and false on reject or close (button, escape, backdrop, replacement by a dialog with the same identifier). See await the choice with confirm, rich content and reactive buttons.
ts
import { useDialog } from 'maz-ui/composables/useDialog'
const dialog = useDialog()
const confirmed = await dialog.confirm({
title: 'Delete user',
message: 'This action cannot be undone.',
})