Click Outside

Example

svelte
<script>
  import { clickOutside, type ClickOutsideEvent } from '@eirikk/sveltekit-stuff';

  function handleClickOut(event: ClickOutsideEvent) {
    console.log('you clicked outside of this div: ', event.detail);
  }
</script>

<div use:clickOutside on:clickOut={handleClickOut} />

Demo

hey click outside me
NPM version