SimpleBar for Vue

2.4.2 · active · verified Sun Apr 19

simplebar-vue is a Vue.js component wrapper for the highly customizable native JavaScript scrollbar library, SimpleBar. It enables developers to easily integrate custom scrollbars into their Vue applications, leveraging native browser scroll behavior for performance while offering extensive styling options. The current stable version of simplebar-vue is 2.4.2, which depends on SimpleBar core v6.x. The core SimpleBar library itself sees fairly regular updates, including major version bumps with breaking changes, which are then reflected in subsequent simplebar-vue releases. Its key differentiator lies in its approach to custom scrollbars: instead of recreating scroll behavior with JavaScript, it maintains the native scrolling experience, ensuring accessibility and performance, particularly for internal web page scrolling areas like chat boxes or modals, rather than the entire `body` element.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to register and use the simplebar-vue component within a Vue 3 application, including importing its necessary CSS, and applying it to a container with overflowing content to create a custom scrollbar.

import { createApp } from 'vue';
import simplebar from 'simplebar-vue';
import 'simplebar-vue/dist/simplebar.min.css';

const app = createApp({
  components: {
    simplebar,
  },
  template: `
    <div id="app-wrapper" style="height: 300px; width: 400px; border: 1px solid #eee;">
      <h2>Content inside SimpleBar</h2>
      <p>This is some content that will be scrollable using SimpleBar.</p>
      <simplebar data-simplebar-auto-hide="false" style="max-height: 250px;">
        <div style="height: 500px; padding: 20px;">
          <p v-for="n in 20" :key="n">Scrollable content line {{ n }}.</p>
          <p>More content to make it scroll.</p>
        </div>
      </simplebar>
      <p>Content outside SimpleBar.</p>
    </div>
  `,
});

app.mount('#app-wrapper');

view raw JSON →