npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lionad/use-scrollbar

v0.5.0

Published

Cover components' native scrollbars with fully customizable virtual scrollbars, built for Vue 3

Readme

@lionad/use-scrollbar

use-scrollbar replaces a component's native scrollbar with a fully customizable one — ideal for styling third-party widgets like tables. Not to be confused with virtual scrolling; this is purely a scrollbar overlay.

Features

  • Powerful API, able to deal with complex components[^1], such as vxe-table、ant-vue-table
  • Customizable, so that you can create your own scrollbar style, animation and user interaction
  • Theme, integrated with these style configurations: ElementPlus, Steam, CSS-Tricks ...
  • Full Typed, with the power of typescript
  • SSR Safe, DOM access is guarded and silently skipped on the server

[^1]: which is not possible with other libraries

Preview

Install

pnpm add @lionad/use-scrollbar

Using Nuxt? Try the companion module @lionad/use-scrollbar-nuxt for auto-imports and style injection.

Usage

import { useScrollbar } from '@lionad/use-scrollbar'
import { ref } from 'vue'

// dont forget to import style.css
// in your main.ts (or entry.ts anyway)
import '@lionad/use-scrollbar/dist/style.css'

const componentOrElementRef = ref(null)
const barStates = useScrollbar(componentOrElementRef, {
  // override default options
})

Live demos (vxe-table, antd-vue-table, AG Grid, Tabulator, CodeMirror 6, Element Plus Table): playground

Document

States

barStates.theme

改变滚动条样式。

const theme = 'normal' // 'normal' | 'steam' | 'css-tricks'
barStates.theme = theme

barStates.offset

改变滚动条相对挂载元素的偏移量。

barStates.offset.y.top = 10 // px
barStates.offset.y.right = 10 // px
barStates.offset.x.left = 5 // px
barStates.offset.x.bottom = 5 // px

几何契约:thumb 的位置与长度由 offset 驱动的内联样式决定,而轨道(.c-scrollbar-track)的 CSS 是 inset: 0; width: 100%; height: 100% 过约束布局( LTR 下 right/bottom 被忽略,恒铺满容器)。想给滚动条贴边留白时直接改 offset;覆写轨道的 right/bottom 无效,覆写 thumb 内联样式需要 !important,两者都不推荐。

barStates.scrollTop / barStates.scrollLeft

如果传入多个 wrapper,那么 scrollTop 属性等同于这几个 wrapper 对应 DOM 元素的最大的哪个 scrollTop 属性。

scrollTop / scrollLeft 是只读镜像(由内部滚动位置同步写出)。程序化滚动请使用 barStates.scrollTo(x, y);给 scrollTop 赋值不会驱动内容滚动。 scrollLeft 同理。

barStates.isDragging

判断当前滚动条是否处于拖动状态。

console.log(barStates.isDragging.y)

barStates.isScrolling

获取当前滚动区域的滚动状态。

console.log(barStates.isScrolling.x)

Actions

barStates.init

如果不是通过显式初始化(即 useScrollbar(elem))的方式自动初始化滚动条,那么需要使用 init 方法手动初始化。init 方法提供了对控制滚动区(甚至多个滚动区)所需要的更细致的参数。

const $parent = cmptRef.value.$el.parentElement
const $wrapper = $parent.querySelector('.content-wrapper')
const $content = $parent.querySelector('.content')

// 详细 API 见类型文档
barStates.init({
  mount: cmptRef.value,
  content: [$content],
  // 可以不传,默认为 content 的上一级父元素
  wrapper: [$wrapper],
  // 可以不传,默认为 wrapper 或 wrapper 的第一个元素
  viewport: $wrapper,
})

barStates.visibleOnHover

监听传入元素的鼠标事件,mouseenter 时显示滚动条,mouseleave 时隐藏滚动条。

barStates.setOffset

根据传入元素的尺寸自动设置滚动条的偏移量。典型场景:弹窗内容区填充了 position:sticky 头部,y 轴滚动条的上方偏移量应为头部高度——传入头部元素即可动态跟踪。

const cmptOrElemRef = ref(null)

barStates.setOffset({
  y: {
    top: cmptOrElemRef,
  },
})

Hooks

useScrollbar

等同于 useScrollbars,用于将一个已有的滚动系统的原生滚动条替换为虚拟滚动条,也是这个库最主要的功能。

useNativeScrollbar

获取原生滚动条相关的一些信息,如宽度。

const nativeBar = useNativeScrollbar()

console.log(nativeBar.thick) // usually 17px in Windows

License

MIT License