profile
viewpoint

Ask questionsClick outside event?

Hi,

Is there a click outside event available?

sveltejs/svelte

Answer questions cbenz

I prefer this implementation which uses a Svelte action (<div use:clickOutside={handleClickEvent}>) because it does not require adding an extra <div>.

https://github.com/rster2002/svelte-outside-click

There is also this REPL example: https://svelte.dev/repl/0ace7a508bd843b798ae599940a91783?version=3.16.7 (I can't find the original author).

useful!

Related questions

Javascript Interpolation in Styles via CSS Variables? hot 2
Svelte applications fail to load in IE 11. Similar loading issue with the main site svelte.dev hot 1
Uncaught TypeError: y.fragment.l is not a function hot 1
Increase elements when using a combination of await block and transition hot 1
Svelte applications fail to load in IE 11. Similar loading issue with the main site svelte.dev hot 1
Change body class via &lt;svelte:body /&gt; hot 1
Site: Svelte Cookbook/ Examples hot 1
Missing dependencies in svelte/compiler type definitions hot 1
Multiple components in one file - svelte hot 1
onMount Error: Function called outside component initialization hot 1
A way to see if slot prop is present hot 1
slot inside #if inside #each : TypeError cannot read property 'd' of null hot 1
unclear / difficult to import uuidv4 hot 1
Use <script type="application/ld+json"> in <svelte:head> hot 1
Error: 'default' is not exported when using babel + moment hot 1
Github User Rank List