Vue Universal Modal is a lightweight and simple modal plugin specifically designed for Vue 3 applications, leveraging Vue's built-in `teleport` feature. Currently at version 1.1.4, its release cadence appears to be relatively infrequent, with updates primarily focusing on bug fixes and dependency bumps since its last feature addition in v1.1.0 in April 2021. Key differentiators include its reliance on `teleport` for efficient DOM management, built-in accessibility (A11Y) features, and support for Server-Side Rendering (SSR) by requiring a pre-defined teleport target in the HTML. It provides essential modal functionalities like add/remove, visibility control, transitions, and automatic keyboard/mouse binding for closing, making it a robust solution for managing modals in modern Vue applications.
npm install vue-universal-modalVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install `vue-universal-modal` as a Vue 3 plugin and integrate a basic modal into a component using `v-model` for visibility control.
Migrate from `v-if="isShow"` to `v-model="isShow"` on your `<Modal>` component. Ensure your `close` prop function updates the v-model bound variable.
Ensure your project is running Vue 3. If you are on Vue 2, you will need to find an alternative modal solution or migrate your application to Vue 3.
Add a target HTML element (e.g., `<div id="modals"></div>`) to your `index.html` file, typically just before the closing `</body>` tag, and configure the plugin with `teleportTarget: '#modals'` (or your chosen selector).
Apply your custom CSS to the content within the `<Modal>` slot and, if necessary, override default styles or provide your own for the modal backdrop and container via CSS.
Ensure `app.use(VueUniversalModal, { ... })` is called before mounting your app, and that you are using the correct `modalComponent` name (default is 'Modal') in your template.This plugin is for Vue 3. Ensure you are importing `createApp` from 'vue' and calling `app.use()` on the application instance returned by `createApp()`.
Change the usage from `<Modal v-if="isShow" ...>` to `<Modal v-model="isShow" ...>`. The `v-model` directive correctly manages the presence of the component in the DOM for transitions.