<template> <AcceleratorModal :on-close="onClose"> <template #trigger> <AcceleratorButton>With close function</AcceleratorButton> </template> <template #content> <p>This modal will call a function when closed or clicked outside</p> </template> </AcceleratorModal></template><script setup lang="ts">function onClose() { console.log('Modal closed');}</script>
<template> <AcceleratorModal :on-confirm="onConfirmAsync" :close-on-confirm="false"> <template #trigger> <AcceleratorButton>Don't close on confirm</AcceleratorButton> </template> <template #content> <p>This modal will not close after successful confirmation</p> </template> </AcceleratorModal></template><script setup lang="ts">async function onConfirmAsync() { await Promise.resolve(); console.log('Modal confirmed');}</script>
<template> <AcceleratorModal disable-trigger> <template #trigger> <AcceleratorButton disabled>Disable trigger</AcceleratorButton> </template> <template #content> <p>This modal has a disabled trigger</p> </template> </AcceleratorModal></template>
Controlled
<template> <AcceleratorModal v-model:open="open"> <template #trigger> <AcceleratorButton>Open state controlled with v-model</AcceleratorButton> </template> <template #content> <AcceleratorButton variant="secondary" @click="open = false">Current state: {{ open }} click to close modal programmatically</AcceleratorButton> </template> </AcceleratorModal></template><script setup lang="ts">const open = ref(false);</script>
No trigger
<template> <AcceleratorButton @click="openNoTrigger = true">Open modal with no trigger</AcceleratorButton> <AcceleratorModal v-model:open="openNoTrigger"> <template #content> <p>This modal has no trigger</p> </template> </AcceleratorModal></template><script setup lang="ts">const openNoTrigger = ref(false);</script>
No footer
<template> <AcceleratorModal :show-footer="false"> <template #trigger> <AcceleratorButton> Open modal with no footer </AcceleratorButton> </template> <template #content> <p>This modal has no footer</p> </template> </AcceleratorModal></template>
<template> <AcceleratorModal> <template #trigger> <AcceleratorButton>Modal with header</AcceleratorButton> </template> <template #header> <h3>Custom Header Title</h3> <p>This is a custom header with additional information</p> </template> <template #content> <p>This modal has a custom header section above the main content.</p> </template> </AcceleratorModal></template>
Props
closeOnOutsideClick:boolean— optional
default:true
Closes the modal on outside click. Set to false to keep this modal and its parent overlays open.
closeOnConfirm:boolean— optional
default:true
Closes the modal after the onConfirm callback is finished.
awaitOnConfirm:boolean— optional
default:true
Waits for the onConfirm callback to resolve before closing the modal.
onConfirm:function— optional
default:undefined
Callback function to be called when the confirm button is clicked.
onClose:function— optional
default:undefined
Callback function to be called when the modal is closed.
disableConfirm:boolean— optional
default:false
Disables the confirm button.
preserveContent:boolean— optional
default:false
Preserves the modal content when closed.
disableTrigger:boolean— optional
default:false
Disables the trigger element.
modalClass:string— optional
default:undefined
Custom CSS class for the modal.
showFooter:boolean— optional
default:true
Controls whether the footer is displayed. Set to false to hide the footer.
confirmText:string— optional
default:Confirm
Text for the confirm button.
closeText:string— optional
default:Close
Text for the close button.
Bindings
v-model:open:boolean
Controls whether the modal is open.
Emits
@update:open
Emitted when the modal open state changes.
Slots
The modal component provides the following slots for customization.
#trigger
The element that triggers the modal on click. This is typically a button. Optional if using v-model:open.
#header
The header content displayed above the main modal content.