Skip to content

此页面的翻译正在准备中,暂时显示英文原文。

enableBodyScrollLock

enableBodyScrollLock is a utility function that locks the body scroll. It prevents the body from scrolling by applying fixed positioning. This is useful when opening modals, drawers, or other overlay components. Safe to call in SSR environment (no-op on server). Calling multiple times has no effect until unlocked.

Interface

ts
function enableBodyScrollLock(): void;

Parameters

Return Value

  • void

Example

tsx
// When modal opens
enableBodyScrollLock();

// When modal closes
disableBodyScrollLock();

基于 MIT 许可证发布。