This package provides a simple Vue.js directive, `v-click-outside`, designed to detect clicks that occur outside of the element it is bound to. Primarily developed for Vue 2, the package (version 1.1.0) was last published over six years ago, indicating it is no longer actively maintained. Its straightforward implementation allows developers to easily create components like dropdowns or modals that close when a user clicks anywhere outside their boundaries. Due to its age, it does not support Vue 3's directive API changes or Composition API patterns. For modern Vue 3 projects, developers should consider updated alternatives like `@vueuse/core`'s `onClickOutside` composable or `v-click-outside` from other maintainers that have been updated for Vue 3.
npm install vue-click-outsideVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and locally register the `v-click-outside` directive to create a toggleable popup that closes when clicking anywhere outside of it. This example is for Vue 2 applications.
For Vue 3, use a modern alternative such as `@vueuse/core`'s `onClickOutside` composable or `vOnClickOutside` directive, `v-click-outside` by ndelvalle (which has Vue 3 support), or implement a custom click-outside directive using Vue 3's Composition API.
Migrate to a contemporary `click-outside` solution built for modern Vue, such as `@vueuse/core` or other dedicated Vue 3 directives/composables.
Ensure the click event that *opens* the element has event propagation stopped. For example, use `@click.stop` on the button or element that toggles the visibility of the element with `v-click-outside`.
If adapting this directive manually, ensure that the element triggering the 'outside' event is not the same as the element itself or its children, typically by checking `event.target` against the element and its `contains` method, or by explicitly setting an ignored element reference as shown in the package's `mounted` hook.
Ensure that `ClickOutside` is imported from 'vue-click-outside' and explicitly listed in the `directives` option of your Vue component, e.g., `directives: { ClickOutside }`.This package is not compatible with Vue 3. You must use a Vue 3-compatible click-outside solution. This includes using a dedicated Vue 3 library or implementing a custom directive/composable designed for Vue 3.
No dependency data recorded yet.