react-remove-scroll-bar

中文文档
2.3.8发布于 2024/12/15MITTypeScriptESM + CJS近 30 天下载 3亿

删除没有内容的正文卷轴 摇摆

中文使用文档

反应- 移动- 滚动- 栏

npm bundle size downloads


v1+用于反应 15,v2+需要反应 16.8+

删除滚动条( 通过设置) overflow: hidden 并保留了卷轴条"gap".

读取 - 它只是使卷轴条隐形.

如果滚动栏不占用任何空间,则什么都不做.

使用量

import {RemoveScrollBar} from 'react-remove-scroll-bar';

<RemoveScrollBar /> -> no scroll bar

右边框

防止内容跳出 位置:已固定 元素为 right:0 应当应用额外的类名. 它只会提供 非零 是的,当它需要的时候, 保持正确的"差距".

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(不包括tslib).

滚动- Locky

所有代码都是因为 反应- 滚动- 锁定 复设相.

条款

有一篇关于防止身体卷轴的中篇文章 如何对抗卷轴

许可证

麻省理工学院

版本与发布记录

react-remove-scroll-bar 共发布 20 个版本,首次发布于 2019/01/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.3.8latest2024/12/151.9 年前
2.3.72024/12/151.9 年前
2.3.62024/03/142 年前
2.3.52024/02/192 年前
2.3.42022/10/134 年前
2.3.32022/06/064 年前

关于 react-remove-scroll-bar 的常见问题

react-remove-scroll-bar 是什么?

删除没有内容的正文卷轴 摇摆

如何安装 react-remove-scroll-bar?

在项目目录运行 npm install react-remove-scroll-bar,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

react-remove-scroll-bar 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

react-remove-scroll-bar 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

react-remove-scroll-bar 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

react-remove-scroll-bar 可以商用吗?

react-remove-scroll-bar 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

react-remove-scroll-bar 的下载量有多少?

根据 npm 官方下载统计,react-remove-scroll-bar 在 2026/10/07 – 2026/11/05 这 30 天内被下载 302,852,838 次,日均约 10,095,095 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

react-remove-scroll-bar 还在维护吗?

最新版本 2.3.8 发布于 2024/12/15(1.9 年前);至今共发布 20 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/01/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。