Simple Modal logic with vue


103.1.15 years ago5 years agoMinified + gzip package size for @lassehaslev/vue-modal in KB



Simple Modal logic with Vue2


Run npm install @lassehaslev/vue-modal --save in your project folder


Use this simple modal with Bulma.

import { Modal } from '@lassehaslev/vue-modal';
export default {
    template: `
        <a @click="open" class="button is-primary is-large" href="#">Open a simple modal</a>
        <modal ref="modal">
            <!-- Modal content Start -->
            <div class="box has-text-centered">
                <h1 class="title">
                    First modal
            <!-- Modal content END -->
    methods: {
        open() {
    components: {

Extend / Build your own!

Just include the BaseModal class as a mixin, and you are good to call open and close and checking isShowingModal boolean.

import BaseModal from '@lassehaslev/vue-modal';

export default {
    template: `
    <div v-show="isShowingModal" class="modal is-active">
        <div class="modal-background" @click="close"></div>
        <div class="modal-content">
        <button class="modal-close" @click="close"></button>

    mixins: [ BaseModal ],


# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

For detailed explanation on how things work, consult the docs for vue-loader.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.