1.2.61 • Published 5 years ago

v-simple-modal v1.2.61

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

V-Simple-Modal

🗃 A simple vue modal. Perfect for all your modal/ dialogs scenarios.

npm

📺 Live Demo

CodeSandbox Code: Link CodeSandbox Demo: Link

🛠 Install

npm i v-simple-modal
yarn add v-simple-modal

🚀 Usage

<template>
  <button size="sm" @click="openModal('modal1')">Basic Modal</button>
  <v-simple-modal ref="modal1" title="Funny, Modal Works 🥳">
    Hello Peeps from V-Simple-Modal!!
  </v-simple-modal>

  <button size="sm" @click="openModal('backdrop-modal')">Basic Modal (with blur backdrop)</button>
  <v-simple-modal ref="backdrop-modal" backdropBlur title="Funny, Modal Works 🥳">
    Wow!! Backdrop is blurred out 🔥
  </v-simple-modal>
</template>

<script>
  import VSimpleModal from 'v-simple-modal';

  export default {
    components: {
      VSimpleModal,
    },

    methods: {
      openModal(ref) {
        this.$refs[ref].open();
      },

      closeModal(ref) {
        this.$refs[ref].close();
      },
    },
  };
</script>

Nuxt.js

After installation,

  • Create a file /plugins/v-simple.modal.js

    import Vue from 'vue';
    import VSimpleModal from 'v-simple-modal';
    
    Vue.component('v-simple-modal', VSimpleModal);
  • Update nuxt.config.js

    module.exports = {
      ...
      plugins: [
        { src: '~plugins/v-simple.modal', mode: 'client' }
        ...
      ]
    }
  • In the page/ component
    <client-only>
      <v-simple-modal ref="modal1" title="Funny, Modal Works 🥳">
        Hello Peeps from V-Simple-Modal!!
      </v-simple-modal>
    </client-only>

Note For older Nuxt versions, use <no-ssr>...</no-ssr> tag

⚙ Props

NameTypeDefaultDescription
titleStringMs Modal titleThe modal title (text only). For HTML, use the header slot.
sizeStringmThe size of the modal. One of s, m, l, fullscreen, or auto. Setting the size to auto will make the modal's width grow to fit its content.
alignTopBooleanfalseWhether or not the modal should be vertically aligned to the top of the viewport. When true, the modal will be top aligned, instead of vertically centered.
alignTopMarginNumber60The modal's distance from the top of the viewport, in pixels. Applies only when the alignTop prop is true.
roleStringdialogThe ARIA role for the modal (important for accessibility). One of dialog or alertdialog.
removeHeaderBooleanfalseWhether or not the modal header is removed.
removeCloseButtonBooleanfalseWhether or not the header close button is removed.
preventShiftBooleanfalseWhether or not to add a dummy scrollbar to the modal backdrop to prevent the modal shifting horizontally when the <body> scrollbar is hidden. Set to true to prevent the modal shift.
dismissibleBooleantrueWhether or not the modal can be dismissed. Set to false to prevent the user from dismissing the modal. This will also hide the header close button.
dismissOnStringbackdrop close-button escThe type of event or events that will cause the modal to be dismissed. One or more of backdrop, close-button, or esc. Separate multiple events with a space.

📎 Slots

You can define own item markup via slots:

NameDescription
(default)Holds the modal body and can contain HTML.
headerHolds the the modal header and can contain HTML.
footerHolds the the modal footer and can contain HTML.

🔥 Events

NameDescription
openEmitted when the modal starts to open. Listen for it using @open.
revealEmitted when the modal is revealed (i.e. when the transition completes). Listen for it using @reveal.
closeEmitted when the modal starts to close. Listen for it using @close.
hideEmitted when the modal close transition completes. Listen for it using @hide.
1.2.61

5 years ago

1.2.6

5 years ago

1.2.59

5 years ago

1.2.52

5 years ago

1.2.53

5 years ago

1.2.51

5 years ago

1.2.56

5 years ago

1.2.57

5 years ago

1.2.54

5 years ago

1.2.55

5 years ago

1.2.58

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago