Skip to content

Modal

<pa-modal> | PaModal

A customizable modal dialog component that provides a consistent way to display overlay content in your Vue 3 applications. The modal includes built-in form validation, customizable buttons, and flexible content areas for displaying forms, confirmations, or any content that requires user focus.

vue
<pa-modal title="Example Modal">
  <p>Modal content goes here</p>
</pa-modal>

Examples

Basic Modal

vue
<template>
  <div>
    <pa-button variant="primary" @click="showModal">Show Basic Modal</pa-button>
    
    <pa-modal
      ref="modal"
      title="Basic Modal"
      ok-title="Got it"
      cancel-title="Close"
      @hide="onModalHide"
    >
      <h5>Welcome!</h5>
      <p>This is a basic modal example with custom button text.</p>
    </pa-modal>
  </div>
</template>

Control the modal width with the size property.

vue
<template>
  <div>
    <div style="display: flex; gap: 0.5rem; flex-wrap: wrap;">
      <pa-button variant="primary" @click="showModal('sm')">Small</pa-button>
      <pa-button variant="primary" @click="showModal('md')">Default</pa-button>
      <pa-button variant="primary" @click="showModal('lg')">Large</pa-button>
      <pa-button variant="primary" @click="showModal('xl')">Extra Large</pa-button>
    </div>
    
    <pa-modal ref="modal" :title="modalTitle" :size="modalSize">
      <p>This is a {{ modalSize || 'default' }} size modal</p>
    </pa-modal>
  </div>
</template>

Importing

js
import { PaModal } from '@payadvantage/ui-components'

Slots

Slot NameDescription
defaultMain content area of the modal. Can contain any HTML, Vue components, or form elements.

Properties

PropertyTypeDefaultDescription
titleString''The title displayed in the modal header
okTitleString'Okay'Text for the OK/submit button
okSubmittingTitleString'Okay'Text for the OK button when submitting (loading state)
cancelTitleString'Cancel'Text for the cancel button
sizeString''Modal size: 'sm', '' (default), 'lg', or 'xl'
hideFooterBooleanfalseWhether to hide the modal footer (buttons)
hideOkButtonBooleanfalseWhether to hide the OK button (keeps cancel button)
fullWidthButtonsBooleanfalseWhether to make footer buttons full width
centeredBooleantrueWhether to vertically center the modal
submitDelegateFunctionnullCustom submit handler function. Return false to prevent modal from closing, true to allow closing. Can be async.

Events

EventParametersDescription
hideevent: { trigger: string }Emitted when modal is hidden. Trigger values: 'ok', 'cancel', 'headerclose', 'backdrop', 'escape'
shownevent: ObjectEmitted when modal is fully shown
hiddenevent: ObjectEmitted when modal is fully hidden

Methods

MethodParametersDescription
show()NoneProgrammatically show the modal
hide(trigger?)trigger?: stringProgrammatically hide the modal with optional trigger
submit()NoneTrigger the modal's submit logic
checkValidity()NoneCheck if the modal's form is valid
resetValidity()NoneReset the form validation state

Dependencies

  • pa-b-modal - Internal foundation component (not documented for consumer use)
  • pa-button - Used for footer buttons
  • pa-form - Wraps modal content for form validation
  • pa-modal-close-button - Provides the header close button