Skip to main content
K
Last modified: 24/Jun/2024

useScrollLock

This hook is used to lock the scroll on the body element.

#Usage

import { useScrollLock, Modal } from '@kinsta/stratus' const MyComponent = () => { const { setScrollEnabled } = useScrollLock() useEffect(() => { if (!disableScroll) { return } setScrollEnabled(false) return () => setScrollEnabled(true) }, [setScrollEnabled]) return <Modal isVisible>{children}</Modal> }

#Parameters

#removeScrollbar
boolean
Remove the scrollbar - Defaults to true
#maintainFixedFullWidthElements
boolean
Maintain the full width for fixed elements - Defaults to true