Thin yet powerful modal component of Vue.js
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


vue-thin-modal provides thin but powerful modal component. Its styles, transitions and contents are fully customizable.


$ npm install --save vue-thin-modal
# or
$ yarn add vue-thin-modal


  1. Import VueThinModal and install it in Vue constructor.
import Vue from 'vue'
import VueThinModal from 'vue-thin-modal'


new Vue({
  // ...
  1. (Optional) Import base CSS file for the modal wherever you want or you can define your own styles.
import 'vue-thin-modal/dist/vue-thin-modal.css'
  1. Use <modal> component in your apps. You can see this.$modal in your components
    <button type="button" @click="open">Open Modal</button>
    <modal name="example">
      <div class="basic-modal">
        <h1 class="title">Modal Title</h1>
        <button class="button" type="button" @click="close">Close Modal</button>

export default {
  methods: {
    open () {

    close () {

Auto installing vue-thin-modal

If you have Vue constructor on window, you don't need to call Vue.use(VueThinModal) since it will be called automatically. This is the case when you load Vue.js and vue-thin-modal via <script> element.

Manually mount portal

By default, the modal content will be automatically sent just under the <body> element by <modal-portal> component. You can disable this behavior by setting autoMountPortal: false option.

import Vue from 'vue'
import VueThinModal from 'vue-thin-modal'

Vue.use(VueThinModal, {
  autoMountPortal: false

In that case, you have to put <modal-portal> by yourself.

  <div id="app">
    <!-- Application body goes here -->

    <modal-portal />

This is useful when you want to inject some plugin instances from the root Vue instance because the auto-mounted portal will not belong to the user defined root Vue instance. For example, you need to put the portal manually when you use vue-i18n plugin.

import Vue from 'vue'
import VueI18n from 'vue-i18n'
import VueThinModal from 'vue-thin-modal'

Vue.use(VueThinModal, {
  autoMountPortal: false


// Create VueI18n instance with options
const i18n = new VueI18n({
  // vue-i18n options

new Vue({
  el: '#app',

  // Since you need to inject i18n instance here,
  // you should put <modal-portal> by yourself.

  // ... remaining options ...


<modal> component


  • name - String, required

    Required as the modal name. The name must be unique against every modal you would use.

  • pre-mount - Boolean

    If true, the modal contents will be pre mounted into the DOM tree. It is useful if you want to pre load the large images on your modal contents before opened.

  • disable-backdrop - Boolean

    If true, the modal will not be closed by clicking backdrop.

  • content-transition - Object

    It is the same options as the props of Vue's <transition> component. You can customize the modal content transition by using this prop. If omitted a default transition will be used.

  • backdrop-transition - Object

    Same as content-transition except for the modal backdrop.


  • before-open

    Emitted before opening a modal.

  • opened

    Emitted after opening a modal.

  • before-close

    Emitted before closing a modal.

  • closed

    Emitted after closing a modal.


  • (default) - A modal content. Must be only element.

  • backdrop - A modal backdrop element.

this.$modal mediator


  • currentName

    Returns a modal name that appears currently.


  • push(name: string): void

    Show the modal that cooresponding with the name.

  • pop(): void

    Hide the modal that is appearing.

  • replace(name: string): void

    Hide the modal that is appearing and show a new modal.