TwitterGitHub
Dark LogoStratik / UIbeta
useScrollTo

The useScrollTo hook allows you to scroll smoothly to a specific element or to the top of the page and manages the visibility of elements based on scroll position. This is useful for implementing features like "Back to Top" buttons or revealing elements when the user scrolls down the page.

Parameters
NameTypeDefaultDescription
thresholdnumber300The scroll position threshold for visibility toggle.
Return Values
NameTypeDescription
isVisiblebooleantrue if the current scroll position exceeds the threshold, otherwise false.
scrollfunctionA function to scroll to a specified element or to the top of the page.