apps/mantine.dev/src/pages/hooks/use-window-scroll.mdx
import { UseWindowScrollDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx';
export default Layout(MDX_DATA.useWindowScroll);
The use-window-scroll hook returns the current scroll position and a function to scroll smoothly to a given position:
interface UseWindowScrollPosition {
x: number;
y: number;
}
type UseWindowScrollTo = (position: Partial<UseWindowScrollPosition>) => void;
type UseWindowScrollReturnValue = [UseWindowScrollPosition, UseWindowScrollTo];
function useWindowScroll(): UseWindowScrollReturnValue;
The UseWindowScrollTo, UseWindowScrollPosition, and UseWindowScrollReturnValue types are exported from @mantine/hooks;
import type { UseWindowScrollTo, UseWindowScrollPosition, UseWindowScrollReturnValue } from '@mantine/hooks';