0.0.6 • Published 1 year ago

vue-minimal-modal v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

vue-minimal-modal

Accessible modal dialog component for Vue.js

Installation

To install, you can use npm or yarn:

via npm

npm install vue-minimal-modal

via yarn

yarn add vue-minimal-modal

API documentation

Examples

Here is a simple example of vue-minimal-modal.

<script setup lang="js">
import { ref } from 'vue'
import Modal from 'vue-minimal-modal'
import 'vue-minimal-modal/css'; // if necessary

const isOpen = ref(false)

const setIsOpen = (value) => {
  isOpen.value = value
}

const openModal = () => {
  setIsOpen(true)
}

const closeModal = () => {
  setIsOpen(false)
}
</script>

<template>
  <div>
    <button type="button" @click="openModal">Open Modal</button>
    <Modal :isOpen="isOpen" :onClose="closeModal">
      <button type="button" @click="closeModal">Close Modal</button>
      <h2>I am Vue Minimal Modal.</h2>
    </Modal>
  </div>
</template>

Props

namedescriptiontypedefault
isOpenBoolean describing if the modal should be shown or not.boolean
onCloseSpecify a function to close modal.function
containerSet parent element that the modal will be attached to.string | HTMLElement'body'
shouldCloseOnBackdropClickBoolean indicating if the backdrop should close the modal.booleantrue
shouldCloseOnEscBoolean indicating if pressing the esc key should close the modal.booleantrue
idId attribute to be applied to the modal div.string
classNameClass attribute to be applied to the modal div.string'vue-minimal-modal'
backdropClassNameClass attribute to be applied to the backdrop div.string'vue-minimal-modal-backdrop'
dialogClassNameClass attribute to be applied to the dialog div.string'vue-minimal-modal-dialog'
preventScrollBoolean indicating if open, prevent scrolling.booleantrue
closeTimeoutNumber indicating the milliseconds to wait before closing the modal.number0
roleRole attribute of the modal.string'dialog'
ariaModalAria Modal attribute of the modal.boolean | 'false' | 'true'true
ariaLabelledbyAria Labelledby attribute of the modal.string
ariaDescribedbyAria Describedby attribute of the modal.string

Events

namedescription
afterOpenWhen the modal opened.
afterCloseWhen the modal closed.
0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago