0.1.13 • Published 5 years ago

vmodal v0.1.13

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

vmodal

A Vue component for Bootstrap modals.

Installation

npm install --save vmodal 

Usage

See the included examples.

JavaScript

import Vue from 'vue'
import Modal from 'vmodal'

Vue.component('modal', Modal)

new Vue({
  el: '#app',

  methods: {
    showModal () {
      this.$refs.modal.show()
    }
  }
})

HTML

<div id="app">
  <modal ref="modal">
    <h5 slot="title">Modal title</h5>
    
    <template slot="body">
      <p>Modal body text goes here.</p>
    </template>

    <template slot="footer">
      <button type="button" class="btn btn-primary">Save changes</button>
      <button type="button" class="btn btn-secondary">Close</button>
    </template>
  </modal>

  <button @click="showModal" type="button" class="btn btn-primary">Show Modal</button>
</div>

Api

Methods

NameDescription
showShow the modal.
hideHide the modal.
toggleToggle the modal.

Example:

this.$refs.modal.show()

Props

NameTypeDefaultDescription
backdropBoolean|StringtrueIncludes a modal-backdrop element or static for a backdrop which doesn't close the modal on click.
closeBooleantrueShow close × button.
focusBooleantruePuts the focus on the modal when initialized.
keyboardBooleantrueCloses the modal when escape key is pressed.
sizeStringOptional size: sm, lg or xl.
formObjectA vform object.

Events

NameAttributesDescription
submit(event)Emitted when the form is submitted.
show(event)Emitted immediately when the show method is called.
shown(event)Emitted when the modal has been made visible to the user.
hide(event)Emitted immediately when the hide method has been called.
hidden(event)Emitted when the modal has finished being hidden from the user.

Example:

this.$refs.modal.$on('shown', (e) => {
  console.log('Modal shown')
})

Slots

NameDescription
titleThe modal title.
bodyThe modal body.
footerThe modal footer.
headerThe modal header.
contentThe modal content.
0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago