onClickOutside
Handle clicks outside of a specified element.
onClickOutside
detects clicks that occur outside a specified element's boundaries and executes a
callback function. It's commonly used for dismissible dropdowns, modals, and other interactive
components.
Demo
Has not clicked outside yet.
Status: Enabled
Basic Usage
Advanced Usage
Controlled Listener
The function returns control methods to programmatically manage the listener, start
and stop
and
a reactive read-only property enabled
to check the current status of the listeners.
Here's an example of using onClickOutside
with a <dialog>
:
Options
Whether the click outside handler is enabled by default or not. If set to false
, the handler will
not be active until enabled by calling the returned start
function.
Controls whether focus events from iframes trigger the callback. Since iframe click events don't bubble to the parent document, you may want to enable this if you need to detect when users interact with iframe content.
The document object to use, defaults to the global document.
The window object to use, defaults to the global window.