A Rust/UI hook that locks and unlocks body scrolling, useful for modal dialogs, sheets, and overlays.
utilsdialog
- Copy Demo
Body Scroll Lock Demo
Try scrolling the page. Click the button to lock/unlock body scrolling.
Scroll Status:🔓 Unlocked
Installation
You can run either of the following commands:
# cargo install ui-cli --forceui add demo_use_lock_body_scrollui add use_lock_body_scrollUpdate the imports to match your project setup.
Usage
use crate::components::hooks::use_lock_body_scroll::use_lock_body_scroll;let scroll_locked = use_lock_body_scroll(false);
// Lock body scrolling
scroll_locked.set(true);
// Unlock body scrolling
scroll_locked.set(false);