Skip to content
On this page

NcModal

Props

Prop nameDescriptionTypeValuesDefault
titleTitle to be shown with the modalstring-''
hasPreviousDeclare if a previous slide is availableboolean-false
hasNextDeclare if a next slide is availableboolean-false
outTransitionDeclare if hiding the modal should be animatedboolean-false
enableSlideshowDeclare if the slideshow functionality should be enabledboolean-false
slideshowDelayDeclare the slide intervalnumber-5000
slideshowPausedAllow to pause an ongoing slideshowboolean-false
enableSwipeEnable swipe between slidesboolean-true
spreadNavigationboolean-false
sizeDefines the modal size.
Default is 'normal'.
Available are 'small', 'normal', 'large' and 'full'.
All sizes except 'small' change automatically to full-screen on mobile.
string-'normal'
canCloseDeclare if the modal can be closedboolean-true
darkMakes the modal backdrop black if trueboolean-false
containerSelector for the modal container, pass null to prevent automatic container mountingstring|null-'body'
closeButtonContainedPass in false if you want the modal 'close' button to be displayed
outside the modal boundaries, in the top right corner of the window
boolean-true
additionalTrapElementsAdditional elements to add to the focus traparray-[]
inlineActionsDisplay x items inline<br/>@see Actions component usagenumber-0

Events

Event namePropertiesDescription
previous
next
closeEmitted when the closing animation is finished

Slots

NameDescriptionBindings
actionsList of actions to show
defaultModal content to render

vue
<template>
  <div>
    <NcButton @click="showModal">Show Modal</NcButton>
    <NcModal
      v-if="modal"
      @close="closeModal"
      size="small"
      title="Title"
      :outTransition="true"
      :hasNext="true"
      :hasPrevious="true"
    >
      <div class="modal__content">Hello world</div>
    </NcModal>
  </div>
</template>
<script>
export default {
  data() {
    return {
      modal: false
    };
  },
  methods: {
    showModal() {
      this.modal = true;
    },
    closeModal() {
      this.modal = false;
    }
  }
};
</script>
<style scoped>
.modal__content {
  margin: 50px;
  text-align: center;
}
</style>
vue
<template>
  <div>
    <NcButton @click="showModal">Show Modal with fields</NcButton>
    <NcModal v-if="modal" @close="closeModal" title="Title inside modal">
      <div class="modal__content">
        <h2>Please enter your name</h2>
        <NcTextField label="First Name" :value.sync="firstName" />
        <NcTextField label="Last Name" :value.sync="lastName" />
        <NcButton
          :disabled="!this.firstName || !this.lastName"
          @click="closeModal"
          type="primary"
        >
          Submit
        </NcButton>
      </div>
    </NcModal>
  </div>
</template>
<script>
import NcButton from "../NcButton/index.js";
import NcTextField from "../NcTextField/index.js";

export default {
  components: {
    NcButton,
    NcTextField
  },
  data() {
    return {
      modal: false,
      firstName: "",
      lastName: ""
    };
  },
  methods: {
    showModal() {
      this.firstName = "";
      this.lastName = "";
      this.modal = true;
    },
    closeModal() {
      this.modal = false;
    }
  }
};
</script>
<style scoped>
.modal__content {
  margin: 50px;
  text-align: center;
}

.input-field {
  margin: 12px 0px;
}
</style>

Usage of popover in modal

  • Set container property to .modal-mask to inject popover context of the modal:
vue
<template>
  <div>
    <NcButton @click="showModal">Show Modal</NcButton>
    <NcModal v-if="modal" @close="closeModal" size="small">
      <NcEmojiPicker container=".modal-mask" @select="select">
        <NcButton>Select emoji {{ emoji }}</NcButton>
      </NcEmojiPicker>
    </NcModal>
  </div>
</template>
<script>
export default {
  data() {
    return {
      emoji: "😛",
      modal: false
    };
  },
  methods: {
    showModal() {
      this.modal = true;
    },
    closeModal() {
      this.modal = false;
    },
    select(emoji) {
      this.emoji = emoji;
    }
  }
};
</script>
<style scoped>
.modal__content {
  margin: 50px;
  text-align: center;
}
</style>