---
category: Utilities
---
# useConfirmDialog
Creates event hooks to support modals and confirmation dialog chains.
Functions can be used on the template, and hooks are a handy skeleton for the business logic of modals dialog or other actions that require user confirmation.
## Functions and hooks
- `reveal()` - triggers `onReveal` hook and sets `revealed.value` to `true`. Returns promise that resolves by `confirm()` or `cancel()`.
- `confirm()` - sets `isRevealed.value` to `false` and triggers `onConfirm` hook.
- `cancel()` - sets `isRevealed.value` to `false` and triggers `onCancel` hook.
## Basic Usage
### Using hooks
```vue
Confirm?
```
### Promise
If you prefer working with promises:
```vue
Confirm?
```
## Type Declarations
```ts
export type UseConfirmDialogRevealResult =
| {
data?: C
isCanceled: false
}
| {
data?: D
isCanceled: true
}
export interface UseConfirmDialogReturn {
/**
* Revealing state
*/
isRevealed: ComputedRef
/**
* Opens the dialog.
* Create promise and return it. Triggers `onReveal` hook.
*/
reveal: (
data?: RevealData,
) => Promise>
/**
* Confirms and closes the dialog. Triggers a callback inside `onConfirm` hook.
* Resolves promise from `reveal()` with `data` and `isCanceled` ref with `false` value.
* Can accept any data and to pass it to `onConfirm` hook.
*/
confirm: (data?: ConfirmData) => void
/**
* Cancels and closes the dialog. Triggers a callback inside `onCancel` hook.
* Resolves promise from `reveal()` with `data` and `isCanceled` ref with `true` value.
* Can accept any data and to pass it to `onCancel` hook.
*/
cancel: (data?: CancelData) => void
/**
* Event Hook to be triggered right before dialog creating.
*/
onReveal: EventHookOn
/**
* Event Hook to be called on `confirm()`.
* Gets data object from `confirm` function.
*/
onConfirm: EventHookOn
/**
* Event Hook to be called on `cancel()`.
* Gets data object from `cancel` function.
*/
onCancel: EventHookOn
}
/**
* Hooks for creating confirm dialogs. Useful for modal windows, popups and logins.
*
* @see https://vueuse.org/useConfirmDialog/
* @param revealed `boolean` `ref` that handles a modal window
*
* @__NO_SIDE_EFFECTS__
*/
export declare function useConfirmDialog<
RevealData = any,
ConfirmData = any,
CancelData = any,
>(
revealed?: ShallowRef,
): UseConfirmDialogReturn
```