ilokesto

ClickAway

ClickAway invokes onClickAway when a pointer or touch event occurs outside the element. Forwards ref to the underlying div. Ideal for closing popovers, dropdowns, and menus.

import { ClickAway } from '@ilokesto/utilinent';

<ClickAway onClickAway={() => setOpen(false)}>{children}</ClickAway>

Props

PropTypeDescription
onClickAway(event) => voidInvoked for outside pointer/touch events.
ignoreRefObject[]Additional refs considered "inside".
pointerEventsbooleanDetect pointerdown instead of mousedown/touchstart.

All standard div props and ref are forwarded.

On this page