Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theKashey/react-remove-scroll-bar
Remove document scroll bar. Nothing more
https://github.com/theKashey/react-remove-scroll-bar
Last synced: 3 months ago
JSON representation
Remove document scroll bar. Nothing more
- Host: GitHub
- URL: https://github.com/theKashey/react-remove-scroll-bar
- Owner: theKashey
- Created: 2019-01-18T02:16:42.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-14T09:58:16.000Z (8 months ago)
- Last Synced: 2024-03-15T12:56:04.648Z (8 months ago)
- Language: TypeScript
- Size: 427 KB
- Stars: 77
- Watchers: 3
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
react-remove-scroll-bar
[![npm](https://img.shields.io/npm/v/react-remove-scroll-bar.svg)](https://www.npmjs.com/package/react-remove-scroll-bar)
[![bundle size](https://badgen.net/bundlephobia/minzip/react-remove-scroll-bar)](https://bundlephobia.com/result?p=react-remove-scroll-bar)
[![downloads](https://badgen.net/npm/dm/react-remove-scroll-bar)](https://www.npmtrends.com/react-remove-scroll-bar)
> 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.
# Usage
```js
import {RemoveScrollBar} from 'react-remove-scroll-bar';-> no scroll bar
```### The Right Border
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".
```js
import {zeroRightClassName,fullWidthClassName, noScrollbarsClassName} from 'react-remove-scroll-bar';// to set `right:0` on an element
// to set `width:100%` on an element
// to remove scrollbar from an element
```
# Size
500b after compression (excluding tslib).# Scroll-Locky
All code is a result of a [react-scroll-locky](https://github.com/theKashey/react-scroll-locky) refactoring.# Article
There is a medium article about preventing the body scroll - [How to fight the scroll](https://medium.com/@antonkorzunov/how-to-fight-the-body-scroll-2b00267b37ac)# License
MIT