File: useclickoutside.md | Updated: 11/15/2025
Introducing PrimeReact v11 Alpha 🥁Learn More
SearchK
10.9.7
HOOK
API
Detects outside clicks of a specific element.
Import#
import { useClickOutside } from 'primereact/hooks';
Copy
Basic#
Click the button to display a popup and click outside to hide it.
Show
<div className="relative">
<Button onClick={() => setVisible(true)} label="Show" />
{visible ? (
<div ref={overlayRef} className="absolute border-round shadow-2 p-5 surface-overlay z-2 white-space-nowrap scalein origin-top">
Popup Content
</div>
) : null}
</div>
Copy
Import
Basic
PrimeReact 10.9.7 by PrimeTek