react-remove-scroll is a utility component for React applications that effectively disables scrolling outside of a specified child node. It provides robust scroll blocking for both mouse and touch devices, handles vertical and horizontal scrolling, and adeptly removes the document scrollbar while preserving layout space. Currently stable at version 2.7.2, the library maintains an active release cadence, frequently delivering bug fixes and minor features. Key differentiators include its support for nested scrollable elements, compatibility with React Portals, and a highly optimized bundle size, achieved with a significant 80% reduction in version 2.0.0. It also offers a sidecar pattern for lazy loading the scroll-blocking logic, allowing for further performance optimization.
No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Main component for basic usage. The library primarily uses ES Modules.
This specific named export is from a subpath for lazy loading patterns.
Used in conjunction with the `sidecar` pattern to import only the UI part initially.
Accesses predefined class names for handling fixed elements' widths when scroll is locked.
This example demonstrates how to use the RemoveScroll component to lock the body scroll while a modal-like element is open, allowing only the modal's content to be scrollable. A button toggles the scroll lock state.
Breaking-change detection hasn't run for this library yet.
CVE tracking and dependency tree are planned for a later release.
No traffic data recorded yet.