cube-vue3-modal

A simple, basic, highly customizable and mobile friendly modal component for Vue3.
372
Install
npm install cube-vue3-modal
Latest Version:1.0.5
Vue:3
License:MIT
Last Updated:Mar 15, 2023
Links: GitHub  ·  npm
Maintainer: f7z

Cube Vue3 Modal

Usage

With v-model:

<template>
  <div>
    <button @click="modal = true">Open</button>
    <Modal v-model="modal">
      <!-- The modal content here -->
    </Modal>
  </div>
</template>

<script setup lang="ts">
const modal = ref(false)
</script>

From ref:

<template>
  <div>
    <button @click="openModal">Open</button>
    <Modal ref="modal">
      <!-- The modal content here -->
    </Modal>
  </div>
</template>

<script setup lang="ts">
import Modal from 'cube-vue3-modal'
const modal = ref<InstanceType<typeof Modal>>()

async function openModal() {
  if (modal.value) {
    await modal.value.open()
    alert('The modal is now opened')
  }
}
</script>

Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.

Type Support For .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:

  1. Disable the built-in TypeScript Extension
    1. Run Extensions: Show Built-in Extensions from VSCode's command palette
    2. Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.

Environment variables

Create a .env file with the following variables:

VITE_PORT=8080

Related Packages

vue-slim-modal

Slim modal component for Vue.js

30,308 11
vue-use-modal-context

Vue modal helpers for simplify modal usage

911 4
@ztrehagem/vue-modal

Stacking-managed styleless modal library for Vue.js.

843 0
cube-vue-modal

A simple, basic, highly customizable and mobile friendly modal component for Vue...

798 2
@bardoui/vmodal

Modal for Vue 3

704

Version History

Version Released Vue License
1.0.5 ^3.2.45 MIT
1.0.4 ^3.2.45 MIT
1.0.3 ^3.2.45 MIT
1.0.2 ^3.2.45 MIT
1.0.1 ^3.2.45 MIT
Pre-releases (6)
Version Released Vue License
1.0.0-beta.6 ^3.2.45 MIT
1.0.0-beta.5 ^3.2.45 MIT
1.0.0-beta.4 ^3.2.45 MIT
1.0.0-beta.3 ^3.2.45 MIT
1.0.0-beta.2 ^3.2.45