📄 primereact/hooks/useoverlayscrolllistener

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

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

Introducing PrimeReact v11 Alpha 🥁Learn More

useOverlayScrollListener

Monitors scroll event of a parent element.

Import#


import { useOverlayScrollListener } from 'primereact/hooks';
         

Copy

Basic#


When any ancestor component of the button is scrolled, the overlay gets hidden. This is especially useful to avoid alignment issues when the overlay is attached to the document body via a Portal.

Show

const [bindOverlayScrollListener, unbindOverlayScrollListener] = useOverlayScrollListener({
    target: buttonRef.current,
    listener: handleScroll,
    options: { passive: true },
    when: visible
});
         

Copy

  • Import

  • Basic

PrimeReact 10.9.7 by PrimeTek