Vue.js Modal (Vue 3)
Github
Vue 2
Demo
Github
Vue 2
Demo
  • Guide

    • Installation
    • Introduction
    • Usage
    • Properties
    • Events
    • Slots
    • Other
  • Examples

    • Demo

Usage

Configuration

Configuration options can be passed as a second argument to app.use.

import VModal from 'vue-js-modal'

app.use(VModal, { ... })

dialog: Boolean

Enables dialogs.


componentName: String

Changes component name from "Modal" to any other string value. It is useful when there is already a global "modal" component.

app.use(VModal, { componentName: 'Foo' })
<foo name="example">This is a modal</foo>

dynamicDefaults: object

Default properties that are injected into dynamic modals.

app.use(VModal, { dynamicDefaults: { draggable: true, resizable: true } })

API

Plugin API can be called within any component through this.$modal:


$modal.show(name, params)

Arguments:

name: string - Name of the modal

params?: object - Any data that you would want to pass into the modal (@before-open event handler will contain params in the event)

Description:

Shows a static modal. Modal component can be defined anywhere within the same or any ancestor component.

<template>
    <modal name="example">This is an example</modal>
</template>

<script>
export default {
    name: 'MyComponent',
    mounted () {
        this.$modal.show('example')
    }
}
</script>

$modal.show(component, componentProps, modalProps, modalEvents)

used to show a dynamic modal at runtime

$modal.hide(name)

hide the modal with the given name property

$modal.hideAll()

hide all modals in the application

Last Updated:: 5/23/25, 5:49 PM
Contributors: Yev, thannaske, A7madXatab, Felix Bernhard
Prev
Introduction
Next
Properties