Skip to content

Confirm Dialog

<pa-confirm-dialog> | PaConfirmDialog

A specialized modal dialog component for confirmations that provides a consistent way to display confirmation prompts in your Vue 3 applications. The confirm dialog includes built-in icon support for different confirmation types and extends the base modal functionality with result handling.

vue
<pa-confirm-dialog title="Confirm Action" text="Are you sure you want to proceed?" />

Examples

Basic Confirmation

vue
<template>
  <div>
    <pa-button variant="primary" @click="showConfirmation">Show Confirmation</pa-button>
    
    <pa-confirm-dialog
      ref="confirmDialog"
      title="Confirm Action"
      text="Are you sure you want to proceed with this action?"
      ok-title="Yes, Continue"
      cancel-title="Cancel"
      @close="onConfirmationResult"
    />
  </div>
</template>

<script setup>
import { ref } from 'vue'

const confirmDialog = ref()

const showConfirmation = () => {
  confirmDialog.value?.show()
}

const onConfirmationResult = (result) => {
  console.log('User confirmed:', result)
}
</script>

Warning Type Confirmation

The confirm dialog supports a warning type that displays a warning icon to emphasize the importance of the confirmation.

vue
<template>
  <div>
    <pa-button variant="danger" @click="showDeleteConfirmation">Delete Item</pa-button>
    
    <pa-confirm-dialog
      ref="deleteDialog"
      title="Delete Confirmation"
      text="This action cannot be undone. Are you sure you want to delete this item?"
      type="warning"
      ok-title="Delete"
      cancel-title="Keep Item"
      @close="onDeleteConfirmation"
    />
  </div>
</template>

<script setup>
import { ref } from 'vue'

const deleteDialog = ref()

const showDeleteConfirmation = () => {
  deleteDialog.value?.show()
}

const onDeleteConfirmation = (confirmed) => {
  if (confirmed) {
    // Proceed with delete
    console.log('Item deleted')
  } else {
    console.log('Delete cancelled')
  }
}
</script>

Custom Content with Slot

You can override the default text content by using the default slot for more complex content.

vue
<template>
  <div>
    <pa-button variant="primary" @click="showCustomConfirmation">Show Custom Content</pa-button>
    
    <pa-confirm-dialog
      ref="customDialog"
      title="Custom Confirmation"
      type="warning"
      ok-title="Proceed"
      cancel-title="Cancel"
      @close="onCustomConfirmation"
    >
      <div>
        <h5>Important Changes</h5>
        <p>The following changes will be made:</p>
        <ul>
          <li>User permissions will be updated</li>
          <li>Email notifications will be sent</li>
          <li>Audit log entries will be created</li>
        </ul>
        <p><strong>Do you want to continue?</strong></p>
      </div>
    </pa-confirm-dialog>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const customDialog = ref()

const showCustomConfirmation = () => {
  customDialog.value?.show()
}

const onCustomConfirmation = (confirmed) => {
  console.log('Custom confirmation result:', confirmed)
}
</script>

Disabled OK Button

You can disable the OK button when certain conditions aren't met.

vue
<template>
  <div>
    <pa-button variant="primary" @click="showTermsConfirmation">Show Terms Agreement</pa-button>
    
    <pa-confirm-dialog
      ref="termsDialog"
      title="Terms Agreement"
      text="You must agree to the terms and conditions before continuing."
      ok-title="I Agree"
      cancel-title="Cancel"
      :ok-disabled="!termsAccepted"
      @close="onTermsConfirmation"
    />
  </div>
</template>

<script setup>
import { ref } from 'vue'

const termsDialog = ref()
const termsAccepted = ref(false)

const showTermsConfirmation = () => {
  termsDialog.value?.show()
}

const onTermsConfirmation = (confirmed) => {
  console.log('Terms accepted:', confirmed)
}
</script>

Importing

typescript
import { PaConfirmDialog } from '@payadvantage/ui-components'

Slots

NameDescription
defaultMain content area of the confirmation dialog. If not provided, displays the text prop content. Can contain any HTML or Vue components.

Properties

PropertyTypeDefaultDescription
titleStringrequiredThe title displayed in the dialog header
textStringnullThe confirmation message text. Not displayed if default slot is used
okTitleString'Okay'Text for the OK/confirm button
okSubmittingTitleString'Okay'Text for the OK button when in submitting state
cancelTitleString'Cancel'Text for the cancel button
canSupportSubmittingBooleantrueWhether the dialog supports submitting states
okDisabledBooleanfalseWhether to disable the OK button
hideOkButtonBooleanfalseWhether to hide the OK button completely
typeStringnullDialog type for visual styling. Currently supports 'warning' which displays a warning icon
sfSelectorStringnullSalesforce selector for integration purposes
submitDelegateFunctionnullCustom submit handler function. Can return boolean or Promise<boolean> to control dialog closing

Events

EventDescriptionEvent Detail
closeEmitted when the dialog is closed with the result of the user's choiceboolean - true if OK was clicked, false for cancel or other dismissal
hideEmitted when the dialog is hidden{ trigger: string } - The trigger that caused the hide event
shownEmitted when the dialog is fully shownObject - Modal shown event details
hiddenEmitted when the dialog is fully hiddenObject - Modal hidden event details

Methods

The component extends PaModal functionality through mixins, providing access to standard modal methods:

MethodParametersDescription
show()NoneProgrammatically show the confirmation dialog
hide(trigger?)trigger?: stringProgrammatically hide the dialog

Dependencies

  • PaModal - Base modal component that provides the modal functionality
  • PaIcon - Used to display type-specific icons (e.g., warning icon)
  • PaResultModalMixin - Provides result handling functionality

Usage Notes

  • The confirm dialog automatically handles result tracking - when the user clicks OK, the close event emits true, when they cancel or dismiss otherwise, it emits false
  • The warning type displays a yellow warning triangle icon to emphasize the importance of the confirmation
  • The component inherits all the positioning and sizing features from PaModal through v-bind="$attrs"
  • Custom submit logic can be provided via the submitDelegate prop for async operations before the dialog closes