use_prevent_scroll

Function use_prevent_scroll 

Source
pub fn use_prevent_scroll<F>(
    should_prevent: F,
    hide_delay: Duration,
) -> RenderEffect<()>
where F: Fn() -> bool + 'static,
Expand description

A utility that prevents scrolling on the document body when a condition is true.

This is useful for modals, dialogs, and other overlay components that should prevent background scrolling. It also compensates for scrollbar width to prevent layout shift.

ยงExample

let is_open = RwSignal::new(false);

let _effect = use_prevent_scroll(
    move || is_open.get(),
    Duration::from_millis(200)
);