Skip to content

VfModal

Base modal shell providing backdrop, layout, and slot structure.

Import

typescript
import { VfModal, vfModalRef } from '@zyno-io/vue-foundation';

Basic Usage

vue
<VfModal id="my-modal" close-on-mask-click scrolls close-x :class="['wide']">
    <template #header>Modal Title</template>

    <p>Modal content goes here.</p>

    <template #footer>
        <button @click="save">Save</button>
    </template>
</VfModal>

Props

PropTypeDefaultDescription
idstring--HTML id attribute
closeOnMaskClickbooleanfalseClose when clicking backdrop (also enables Escape key)
scrollsbooleanfalseEnable scrolling in content area
closeXbooleanfalseShow close icon in header
classstring | string[]--CSS classes on the overlay wrapper
onClose() => void--Custom close handler (overrides default dismiss)

Slots

SlotDescription
headerModal header content
defaultModal body content
footerModal footer content

Events

EventDescription
formSubmitThe modal wraps content in a <form>, so submit events bubble up

Exposed Methods

typescript
const modalRef = vfModalRef();

// Mask the modal form (disable inputs, show "Please wait...")
const unmask = modalRef.value.mask();
unmask(); // restore

// Hide/show the modal without destroying it
const unhide = modalRef.value.hide();
unhide();

Use the vfModalRef() helper to create a properly typed ref:

typescript
import { vfModalRef } from '@zyno-io/vue-foundation';

const modal = vfModalRef();
// <VfModal ref="modal" ...>

Demo