Utilities
useScrollLock
Locks scrolling on the page or any element without a layout shift, as dialogs do while they’re open. Use it for your own overlays and full-screen panels.
Locks scrolling on an element, document.body by default. Dialog, Drawer, BottomSheet and Tour use it while they are open. It sets overflow: hidden and overscroll-behavior: contain. It also pads the element's inline end by the scrollbar's width, so the layout doesn't shift when the scrollbar goes. It sets that width as --ui-scrollbar-width too, on <html> for a body lock, so a fixed header can add the same padding. Locks are counted per element: when two dialogs lock the body, it stays locked until both release. On release, the inline styles from before the lock come back, unless something else changed them in the meantime. On iOS, a body lock also blocks touch scrolling, except inside a scrollable region within the body.
Install
import { useScrollLock } from 'vael-ui'