Click-Away Listener
stableCalls a handler when interaction happens outside its child.
Basic usage
Examples
Dismiss a panel
Open a panel and click anywhere outside to close it. Clicks inside are ignored.
Tooltip-style popover
Use with a dropdown or popover surface — inside clicks keep it open.
onClickAway callback
Receives the raw mouse or touch event — use it to close, dismiss, or reset.
Features
- Document-level mouse and touch support.
- No visual wrapper.
Installation
bash
pnpm dlx structyl add click-away-listenerAPI Reference
ClickAwayListener
Outside interaction observer.
| Prop | Type | Default |
|---|---|---|
| onClickAway | (event: MouseEvent | TouchEvent) => voidCalled when the user interacts outside the child. | — |
| children | React.ReactNodeObserved child. | — |