📄 primereact/hooks/useclickoutside

File: useclickoutside.md | Updated: 11/15/2025

Source: https://primereact.org/hooks/useclickoutside/

Introducing PrimeReact v11 Alpha 🥁Learn More

useClickOutside

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