useScrollLock
function useScrollLock(locked: boolean): void;
You are most likely not going to need this hook and instead rely on existing components like the Dialog or Sheet to handle it for you.
The useScrollLock
hook can be used to lock scrolling on the entire page.
Example Usage
function Example() {
const { toggled, toggle } = useToggle();
useScrollLock(toggled);
return <Button onClick={toggle}>Toggle</Button>;
}
Parameters
locked
- Boolean if thedocument.body
should be no longer be scrollable
Returns
Nothing.