usePreventScroll

Prevents scrolling on the document body on mount, and restores it on unmount. Also ensures that content does not shift due to the scrollbars disappearing.

installyarn add react-aria
version3.20.0
usageimport {usePreventScroll} from 'react-aria'

API#


usePreventScroll( (options: PreventScrollOptions )): any

Example#


See useDialog for an example of using usePreventScroll to prevent scrolling on the document body on dialog mount.