@venegrad/vue3-click-outside

Vue click outside directive for vue3 and nuxt3
190,363 5
Install
npm install @venegrad/vue3-click-outside
Latest Version:1.0.2
Vue:3
License:MIT
Last Updated:Jan 14, 2025
Links: GitHub  ·  npm
Maintainer: venegrad

Vue 3 Click Outside directive

Directive for adding click outside event in Vue 3 or Nuxt3

Using in component

<template>
<div class="conainer">
  <div  v-outside="hide">
    <button @click="open = true">{{ open }}</button>
  </div>
</div>
</template>

<script>
import outside from "@venegrad/vue3-click-outside"

export default {
  data() {
    return {
      open: false
    }
  },
  directives: {
    outside
  },
  methods: {
    hide() {
      this.open = false
    }
  }
}
</script>

or u can register it global if need
./src/main.js

import { createApp } from 'vue'
import App from './App.vue'
import outside from "@venegrad/vue3-click-outside"

const app = createApp(App)
app.directive('outside', outside)
app.mount('#app')

Nuxtjs 3

use it as global plugin:
./plugins/global.js

import outside from "@venegrad/vue3-click-outside"

export default defineNuxtPlugin(async (nuxtApp) => {
  nuxtApp.vueApp.directive('outside', outside)
})

Help links:

  • If my solution was helpful to you, please give me a star on Github or get my day better with:
  • USDT TRC20: TKXybH3YoFvT5h8bQFLdkDBtiXA65y7xaB
  • USDT ERC20: 0xc3efeB4825E350eE5D6B032Aa1dE144B09B5bB0D

Related Packages

@venegrad/vue3-code-input

Code input for vue3 and nuxtjs 3. Code input for email or sms confirmations. Typ...

9,008 1
@venegrad/vue3-autocomplete

Simple autocomplete field for vue3 and nuxt3. Tags, async loading list, dynamic,...

6,241 5
nuxt-inline-scripts

Enable/Disable inlineScripts for Nuxt3

3,436 1
click-outside-vue3

Vue 3 directive to react on clicks outside an element

3,633,692 79
v-pagination-3

Vue.js 3 pagination component

823,217 186

Version History

Version Released License
1.0.2 MIT
1.0.1 MIT
1.0.0 MIT