@frsource/light-scrollbar

中文文档
1.7.0发布于 2026/11/12MITTypeScriptESM + CJS构建来源已验证近 30 天下载 1.3万

Minimalistic plugin to create custom scrollbars! 💪

原始使用文档
文档目录11 节
  1. Installation
  2. Modern JS/Typescript
  3. UMD
  4. Rail (optional)
  5. Styles
  6. Documentation
  7. Demo examples
  8. Questions
  9. Changelog
  10. Contribute
  11. License

NPM version badge Core bundle size badge. Data from bundlephobia.com changesets badge Tree shaking supported license MIT badge

Light Scrollbar - minimalistic light plugin to create custom scrollbar! 💪

Getting Started · Documentation · File an Issue · Have a question or an idea?


Light, small library that allows create custom scrollbar.
Mobile & desktop-friendly
Not rebuilding scrolling experience, just visually represent browser scrollbar
Performant & with small bundle size (less than 2500B!)
Possibility to use `scroll-behavior: smooth`
Published as separate bundles for JS ES5 or modern browsers thanks to microbundle
Written completely in typescript

Published under MIT license

https://www.frsource.org/light-scrollbar

Installation

# npm
npm install @frsource/light-scrollbar

# Yarn
yarn add @frsource/light-scrollbar

# Pnpm
pnpm add @frsource/light-scrollbar

Modern JS/Typescript

import { attach } from "@frsource/light-scrollbar";
const scrollingElement = document.querySelector("element-with-overflow-auto");
attach(scrollingElement);

UMD

const scrollingElement = document.querySelector("element-with-overflow-auto");
window.lightScrollbar.attach(scrollingElement);

Rail (optional)

A background track under the scrollbar thumb. It is a separate entry, so it is added to your bundle only when you import it:

import { attach } from "@frsource/light-scrollbar";
import { rail } from "@frsource/light-scrollbar/rail";
import "@frsource/light-scrollbar/dist/rail.css";

// every `rail` value that is not set is taken from `bar`
attach(scrollingElement, { enableRail: true, plugins: [rail], rail: { y: { width: 10 } } });

With UMD, load dist/rail.umd.js and pass window.lightScrollbarRail.rail.

Styles

Colors and radius are CSS variables with defaults included in the styles - override only the ones you want to change, on the scrollbar element, any of its parents or :root:

.my-scrollbar {
  --light-scrollbar-bar-background: #8b5cf6;
  --light-scrollbar-bar-background-active: #6d28d9;
  --light-scrollbar-bar-radius: 2px;
}

With the rail on, the rail and the thumb on top of it use --light-scrollbar-rail-background, --light-scrollbar-rail-radius, --light-scrollbar-rail-bar-background and --light-scrollbar-rail-bar-background-active.

Documentation

For docs, please visit frsource.org/light-scrollbar

Demo examples

Check our examples to see how its working!

Questions

Don’t hesitate to ask a question directly on the discussions board!

Changelog

Changes for every release are documented in the release notes and CHANGELOG file.

Contribute

Development happens in docs, so run pnpm docs:dev which runs microbundle and vitepress docs. Tests can be done in cypress running pnpm cy which runs microbundle and cypress

License

MIT

Copyright (c) 2022-present, Szymon Dziewoński, FRSOURCE

版本与发布记录

@frsource/light-scrollbar 共发布 316 个版本,首次发布于 2022/03/16;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.7.0latest2026/11/123 天前
1.6.12026/11/096 天前
1.6.02026/11/096 天前
1.5.02026/11/069 天前
1.4.2552026/11/0313 天前
1.4.2542026/11/0313 天前

关于 @frsource/light-scrollbar 的常见问题

@frsource/light-scrollbar 是什么?

Minimalistic plugin to create custom scrollbars! 💪

如何安装 @frsource/light-scrollbar?

在项目目录运行 npm install @frsource/light-scrollbar,或使用 pnpm add / yarn add / bun add。

@frsource/light-scrollbar 支持 TypeScript 吗?

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

@frsource/light-scrollbar 支持 ESM 还是 CommonJS?

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

@frsource/light-scrollbar 需要什么版本的 Node.js?

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

@frsource/light-scrollbar 可以商用吗?

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

@frsource/light-scrollbar 的下载量有多少?

根据 npm 官方下载统计,@frsource/light-scrollbar 在 2026/10/16 – 2026/11/14 这 30 天内被下载 13,245 次,日均约 442 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@frsource/light-scrollbar 还在维护吗?

最新版本 1.7.0 发布于 2026/11/12(3 天前);至今共发布 316 个版本,其中过去 12 个月发布了 28 个;首次发布于 2022/03/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。