v-model

Pass a Boolean value to the v-model directive to show and hide the modal window.

Plugin API

The Plugin API exposes show/hide functions that can be called within any component to show and hide the modal window with the given name.
In order to use the Plugin API you need to import and register the modalPlugin.

The functions are available through:

  • useModal in Composition API
  • this.$modal in Options API

Functions

show(name: string): void : Shows the modal with the given name prop
hide(name: string): void : Hides the modal with the given name prop
hideAll(): void - Hides all modals

Props

PropDescriptionTypeDefault
nameThe name of the modal to use with the show / hide functions.StringEmpty
titleThe title of the modal elementStringEmpty
baseZindexThe z-index style attribute of the modal windowNumber1051
wrapperClassExtra CSS classes for the modal wrapperString, Object, ArrayEmpty
bgClassExtra CSS classes for the modal backdropString, Object, ArrayEmpty
modalClassExtra CSS classes for the modal elementString, Object, ArrayEmpty
modalStyleExtra CSS styles for the modal elementObjectEmpty
inClassAnimation class for the modal introString, Object, Arrayvm-fadeIn
outClassAnimation class for the modal outroString, Object, Arrayvm-fadeOut
bgInClassAnimation class for the modal backdrop introString, Object, Arrayvm-fadeIn
bgOutClassAnimation class for the modal backdrop outroString, Object, Arrayvm-fadeOut
appendToElement (selector) in which the modal is to be inserted to, e.g '#modal-host'
This option should not be changed at runtime
Stringbody
liveControls whether the modal renders dynamically or stays hidden in the DOM
This option should not be changed at runtime
Booleanfalse
enableCloseControls whether the modal window is closable or notBooleantrue
modelValueOpens and closes the modal window, this is used by v-model internally.Booleanfalse
closeLabelThe aria-label attribute of the close buttonStringClose

Slots

default

The default slot to use for the content of the modal.

titlebar

The slot to use for overriding the titlebar of the modal

Default value:

<div class="vm-titlebar">
  <h3 class="vm-title">
    {{ title }}
  </h3>
  <button
    v-if="enableClose"
    type="button"
    class="vm-btn-close"
    @click.prevent="close"
  ></button>
</div>

content

The slot to use for overriding the content of the modal

Default value:

<div class="vm-content">
  <slot></slot>
</div>

Events

NameDescription
update:modelValueEvent that is emitted when the component’s model changes
before-openEvent that is emitted before the modal opening transition starts
openingEvent that is emitted while the modal opening transition is in progress
openedEvent that is emitted when the modal is visible and the opening transition ended
before-closeEvent that is emitted before the modal closing transition starts
closingEvent that is emitted while the modal closing transition is in progress
closedEvent that is emitted when the modal is no longer visible and the closing transition ended