Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/netzo/deps/usehooks-ts.ts>useLockedBody

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
function useLockedBody
import { useLockedBody } from "https://deno.land/x/netzo@0.5.63/deps/usehooks-ts.ts";

Custom hook for locking and unlocking the body scroll to prevent scrolling.

Examples

const [isLocked, setLocked] = useLockedBody(true); // Use isLocked to conditionally apply styles or prevent scrolling. // Use setLocked to dynamically control the body scroll lock state.

Parameters

optional
initialLocked: boolean
  • The initial state of body scroll lock (default to false).
optional
rootId: string
  • The ID of the root element to calculate scrollbar width (default to ___gatsby to not introduce breaking change).

Returns

[boolean, (locked: boolean) => void]

A tuple containing the current state of body scroll lock and a function to set the state.