Skip to content


This functionality goes beyond the use of modal windows. However, this mechanism allows you to implement new interface elements, such as notifications, error display, etc. Using namespace you can easily implement components with similar functionality of modal windows.

This article will tell you how to use namespace, as well as An example of creating notifications based on a modal window container will be given.


By default, we create a container without specifying a namespace, but we nothing prevent you from creating a named container:

    <container namespace = "errors" />
<script setup>
    import {container} from "jenesius-vue-modal"

Here we have created a container in which all modal windows will be placed with namespace set to errors.


Methods openModal, pushModal, promptModal are also expanded. In the option you can indicate the namespace that will be used:

import Modal from "my-modal.vue"
import {pushModal} from "jenesius-vue-modal"

pushModal(Modal, {}, { namespace: 'errors' })

This modal window will be added to the errors space and will be displayed in the appropriate container.


Of course, now you need the ability to close not the last modal window, and the last window from the desired container. Methods closeModal, popModal have been expanded. Now in the options, passed as the first parameter, you can specify namespace:

import {closeModal} from "jenesius-vue-modal"
closeModal({namespace: 'errors'})

Standard interaction

What you need to understand is that when we don't specify namespace, we are working with namespace = default. I recommend not specifying it at all if The namespace used is assumed to be the default.

It is important to clarify that only for namespace equal to default The Esc handler is installed. At the moment the implementation forces It’s up to you to take care of closing modal windows in containers other than default.

In the object returned by the pushModal, openModal, promptModal methods a namespace field has appeared, which will be set automatically and store the name of the container.

const modal = await pushModal(Modal, {}, { namespace: 'notification' });
modal.namespace // 'notification'

Gets the current modal window.

The getCurrentModal method has been extended. Now first and optional the parameter is the name namespace for which you want to find the last one open modal window.

getCurrentModal() // Return last opened modal from default namespace
getCurrentModal("notifications") // From namespace: "notifications"

Getting the current queue

In practice, using the second modal-container does not represent many amenities. Other interface elements are very different from the dialog ones (modal) windows. Therefore, it will be more convenient for you to use a queue that stores an array of current elements:

import {getQueueByNamespace} from "jenesius-vue-modal"

const notifications = getQueueByNamespace("notifications");


  • namespace Optional parameter specifying the name namespace.


The method returns a reactive array that stores modal windows.


Let's look at an example of how you can use this library create notifications. We will add a container that will show elements from namespace with name notification.


Let's create the following component:

			v-for="item in notificationQueue"

<script setup>
import {getQueueByNamespace} from "jenesius-vue-modal";

const notificationQueue = getQueueByNamespace("notification")

Let us immediately pay attention to:

  • getting a queue for notification.
  • display messages in v-for.
  • We take the message text from props. It's important to remember that props are ComputedRef.


If instead of p you use your own component, then I recommend use the following:

		   v-for="item in notificationQueue"
           v-bind = "item.props" /> 

This completes the notification functionality. It remains to connect this container in your component, for example App.vue and call one of methods for opening a modal window with namespace: 'notification'.

Released under the MIT License.