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

smooth-vuebar

v2.0.2

Published

Vue 3 directive wrapper for smooth-scrollbar

Downloads

313

Readme

smooth-vuebar

npm version npm downloads CI License: MIT

Vue 3 directive wrapper for smooth-scrollbar

Implements smooth-scrollbar as a Vue 3 directive — the right way to handle this kind of DOM manipulation. Ships full TypeScript types, ESM + CJS builds, and SSR-safe defaults.

Demo

Refer to the upstream library demo.

Install

npm i smooth-vuebar

Import the default CSS (sets max-width/height: 100vw/vh on the scrollable container):

import 'smooth-vuebar/default.css'

Usage

Vue 3 (Composition API / <script setup>)

<script setup>
import { ref } from 'vue'

const onScroll = (status) => {
  console.log('scroll offset:', status.offset)
}
</script>

<template>
  <div v-smoothscrollbar="{ listener: onScroll, options: { damping: 0.1 } }">
    <router-view />
  </div>
</template>

Global plugin (main.ts)

import { createApp } from 'vue'
import SmoothVuebar from 'smooth-vuebar'
import 'smooth-vuebar/default.css'
import App from './App.vue'

createApp(App)
  .use(SmoothVuebar, {
    // optional global defaults (overridden by per-element binding)
    options: { damping: 0.1 },
  })
  .mount('#app')

Nuxt 3 (client-only plugin)

// plugins/smooth-vuebar.client.ts
import SmoothVuebar from 'smooth-vuebar'
import 'smooth-vuebar/default.css'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(SmoothVuebar)
})

Directive binding

<div v-smoothscrollbar="{ listener, options }">

| Field | Type | Default | Description | |-------|------|---------|-------------| | options | Partial<ScrollbarOptions> | undefined | Options forwarded to Scrollbar.init. See smooth-scrollbar docs. | | listener | ScrollListener | undefined | Scroll event listener. Automatically added/removed when the binding changes. |

Global defaults (passed to app.use(SmoothVuebar, { ... })) are used only when the per-element binding does not set the corresponding field.

Events

The directive dispatches native DOM events on the container element:

| Event | When | event.detail | |-------|------|---------------| | @insert | Element mounted and scrollbar initialized | The container HTMLElement | | @unbind | Element about to be unmounted | The container HTMLElement |

<div v-smoothscrollbar @insert="onInit" @unbind="onDestroy">

Accessing the Scrollbar instance

Via component property

// Options API
this.$scrollbar.get(el)

// Composition API — inject the app
import { getCurrentInstance } from 'vue'
const { proxy } = getCurrentInstance()!
proxy!.$scrollbar.get(el)

Via named import

import { Scrollbar } from 'smooth-vuebar'

const instance = Scrollbar.get(el)

Mobile / touch devices

Pass false as the binding value to disable initialization on that element while keeping the directive registered (so Vue does not throw on v-smoothscrollbar). Native momentum scrolling takes over on touch devices.

<script setup>
const isMobile = () => navigator.maxTouchPoints > 1
</script>

<template>
  <!-- false disables init; truthy value (or no value) enables it -->
  <div v-smoothscrollbar="isMobile() ? false : { options: { damping: 0.1 } }">
    <slot />
  </div>
</template>

This resolves issue #7.

Migrating from v1 (Vue 2)

v2.0.0 is a breaking change — it targets Vue 3 only.

| v1 (Vue 2) | v2 (Vue 3) | |------------|------------| | Vue.use(SmoothVuebar) | app.use(SmoothVuebar) | | Vue.prototype.$scrollbar | app.config.globalProperties.$scrollbar or import { Scrollbar } from 'smooth-vuebar' | | Vue.scrollbar | import { Scrollbar } from 'smooth-vuebar' | | smooth-scrollbar ^8.4.0 (lodash-es vuln) | smooth-scrollbar ^8.8.4 (no lodash-es) |

The directive name (v-smoothscrollbar) and binding shape ({ options, listener }) are unchanged.

Releases

  • v2.x — Vue 3, TypeScript, Vite library mode (this branch)
  • v1.x — Vue 2 (no longer maintained; Vue 2 reached EOL December 2023)