On This Page
ClickOutsideListener
A utility component to detect click events outside of a wrapped component.
import { ClickOutsideListener } from '@deque/cauldron-react'
Example#
<ClickOutsideListener onClickOutside={() => alert('You clicked outside!')}>
<Button>Click Inside</Button>
</ClickOutsideListener>
Props#
Name | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | Child content. | |
onClickOutside Required | MouseEvent | TouchEvent | Callback function for event type. | |
mouseEvent | mousedown | click | mouseup | false | click | Event type to listen to for mouse events. |
touchEvent | touchstart | touchend | false | touchend | Event type to listen to for touch events. |
target | HTMLElement | React.RefObject | React.MutableRefObject | Optional element to attach events to if wrapped child does not have an accessible ref. |