useScrollLock
A hook to lock the scroll of the body
Loading...
Installation
npx shadcn@latest add @shadcnhooks/use-scroll-lockAPI
interface UseScrollLockOptions {
autoLock?: boolean
lockTarget?: HTMLElement | string
widthReflow?: boolean
}
interface UseScrollLockReturn {
isLocked: boolean
lock: () => void
unlock: () => void
}
/**
* A hook to lock the scroll of the body
* @param options - The options for the hook
* @param options.autoLock - Whether to automatically lock the scroll when the component is mounted
* @param options.lockTarget - The target element to lock the scroll on
* @param options.widthReflow - Whether to reflow the width of the body when the scroll is locked
* @returns The scroll lock state and the functions to lock and unlock the scroll
*/
function useScrollLock(options?: UseScrollLockOptions): UseScrollLockReturnCredits
Last updated on