vue-modal-provider

A modal state manager for vue.
2,290 37
Install
npm install vue-modal-provider
Latest Version:0.6.0
Vue:3
License:MIT
Last Updated:Nov 6, 2024
Links: GitHub  ·  npm
Maintainer: shijinghui

vue-modal-provider

nice-modal-react vue implementation. Simple to use and manage modal.

Document

HereThe online document.

Installation

$ npm install vue-modal-provider

Examples

Embed your application with ModalProvider

<!--App.vue -->
<script setup lang="ts">
import { RouterView } from "vue-router";
import { ModalProvider } from "vue-modal-provider";
</script>

<template>
  <ModalProvider>
    <RouterView />
  </ModalProvider>
</template>

Create modal component

<!-- Modal.vue -->
<template>
  <el-dialog v-model="visible">
    {{ args }}
    <el-button @click="hide(), resolve(1111), remove()">close</el-button>
  </el-dialog>
</template>

<script lang="ts" setup>
import { useModalRef } from "vue-modal-provider";
const {
  // show variables
  visible,
  // close modal
  hide,
  args,
  // remove modal lose animation
  remove,
  resolve,
  reject,
} = useModalRef();
</script>

Use in the view

<script lang="ts" setup>
import { useModal } from "vue-modal-provider";
import TestModal from "./Modal.vue";
const { show } = useModal(TestModal);

function showModal() {
  show("test msg").then((c) => {
    console.log(c);
  });
}
</script>

<template>
  <el-button @click="showModal">open modal</el-button>
</template>

Related Packages

vue-bootstrap-modal

Bootstrap Style Modal for Vue

1,808 146
vue-modal-wizard

An agressive and powerful modal component for Vue.

1,643 9
@andresouzaabreu/vue-bootstrap-modal

A Vue component for creating reusable bootstrap modals.

735
vue3-layer

基于 Vue 3 和 layui layer 的 Web 通用弹出层组件

3,936

Version History

Version Released Vue License
0.6.0 ^3.4.23 MIT
0.5.0 ^3.4.23 MIT
0.4.1 ^3.4.23 MIT
0.4.0 ^3.4.23 MIT
0.3.1 ^3.2.37 MIT