useLockBodyScroll
Locks page scrolling without layout shift.
1.4 KB
•Updated on September 3, 2026
Installation
Bash
pnpm dlx shadcn@latest add @spaceui/hooks-dom-use-lock-body-scrollUsage
Code
import { useLockBodyScroll } from '@/hooks/use-lock-body-scroll'
const { isLocked, toggle } = useLockBodyScroll(false)API Reference
Parameters / Props
| Parameter | Type | Default | Description |
|---|---|---|---|
initialLocked | boolean | true | Initial state. |
Return Value
| Property | Type | Description |
|---|---|---|
isLocked | boolean | Locked state. |
toggle | () => void | Toggles lock. |