@stradox/vue3-useclickoutside

0.0.5 • Public • Published

Vue3-UseClickOutside

A Vue 3 composable that allows you to run actions when clicking outside an element. Useful for closing modals, dropdowns, etc.

Installation

$ npm install @stradox/vue3-useclickoutside

Usage

<script setup lang="ts">
import { ref } from 'vue';
import { useClickOutside } from '@stradox/vue3-useclickoutside';

const relevantRef = ref<HTMLElement | null>(null);

useClickOutside(relevantRef, () => {
  // do something
});
</script>

<template>
  <div>
    <div ref="relevantRef">Click outside me</div>
  </div>
</template>

Package Sidebar

Install

npm i @stradox/vue3-useclickoutside

Weekly Downloads

3

Version

0.0.5

License

MIT

Unpacked Size

16.2 kB

Total Files

8

Last publish

Collaborators

  • stradox