DOM & Events
useScrollLock
Lock and unlock body scroll for modals and overlays with proper cleanup.
import { useScrollLock } from "saha-ui"Uses
Lock body scrolling (and compensate for scrollbar width) for overlays like modals and drawers.
Props
| Name | Type | Description | Default |
|---|---|---|---|
| isLocked | boolean | Lock state. | - |
Returns
| Name | Description |
|---|---|
| void | No return value; performs side effects on `document.body`. |
Example
useScrollLock(isModalOpen);
Notes
Stores original overflow and paddingRight and restores them on cleanup; calculates scrollbar width to prevent layout shift.