![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
react-remove-scroll-bar
Advanced tools
Package description
The react-remove-scroll-bar package is designed to remove the scroll bar from the page or a specific element without affecting the page layout. It is useful for creating modals, full-screen menus, or other overlay components where you want to prevent background scrolling while the overlay is active.
Remove scroll bar from the entire page
This code sample demonstrates how to remove the scroll bar from the entire page by simply including the <RemoveScrollBar /> component in your application.
import { RemoveScrollBar } from 'react-remove-scroll-bar';
function App() {
return (
<>
<RemoveScrollBar />
{/* rest of your application */}
</>
);
}
Remove scroll bar with gap compensation
This code sample shows how to remove the scroll bar and compensate for the gap that might be left using the 'margin' mode, which adjusts the margin of the body element to fill the space where the scroll bar was.
import { RemoveScrollBar } from 'react-remove-scroll-bar';
function App() {
return (
<>
<RemoveScrollBar gapMode='margin' />
{/* rest of your application */}
</>
);
}
The body-scroll-lock package is similar to react-remove-scroll-bar in that it prevents scrolling on the body element. It provides more granular control over touch events on mobile devices but does not automatically handle the layout shift that can occur when the scroll bar is removed.
React-scrolllock is another package that can be used to lock scrolling on the body. It is similar to react-remove-scroll-bar but does not remove the scroll bar visually; it only disables scrolling interactions.
Readme
v1+ for React 15, v2+ requires React 16.8+
Removes scroll bar (by setting overflow: hidden
on body), and preserves the scroll bar "gap".
Read - it just makes scroll bar invisible.
Does nothing if scroll bar does not consume any space.
import {RemoveScrollBar} from 'react-remove-scroll-bar';
<RemoveScrollBar /> -> no scroll bar
To prevent content jumps position:fixed elements with right:0
should have additional classname applied.
It will just provide a non-zero right, when it needed, to maintain the right "gap".
import {zeroRightClassName,fullWidthClassName, noScrollbarsClassName} from 'react-remove-scroll-bar';
// to set `right:0` on an element
<div className={zeroRightClassName} />
// to set `width:100%` on an element
<div className={fullWidthClassName} />
// to remove scrollbar from an element
<div className={noScrollbarsClassName} />
500b after compression (excluding tslib).
All code is a result of a react-scroll-locky refactoring.
There is a medium article about preventing the body scroll - How to fight the scroll
MIT
FAQs
Removes body scroll without content _shake_
The npm package react-remove-scroll-bar receives a total of 5,839,348 weekly downloads. As such, react-remove-scroll-bar popularity was classified as popular.
We found that react-remove-scroll-bar demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.