SimpleBar Documentation

repository·master·Indexed 27 days ago

https://github.com/grsmto/simplebar

A lightweight (6kb minified) library that replaces default browser scrollbars with customizable CSS-styled ones while preserving native scrolling performance. Includes a vanilla JavaScript plugin and official framework integrations for React (simplebar-react), Angular (simplebar-angular), and Vue (simplebar-vue).

Tokens
5.5K
Snippets
21
Records
53
Agent score
91%

What's inside SimpleBar

  1. Overview of SimpleBar

    master
    SimpleBar replaces the browser's default scrollbar with a custom CSS-styled one without losing performance. Unlike other plugins, it does NOT implement custom scroll behavior; it maintains native overflow: auto scrolling and only replaces the visual appearance of the scrollbar. This ensures native scrolling performance and behavior.
  2. Install SimpleBar via CDN

    master

    For quick integration without a module bundler, you can include SimpleBar via <script> and <link> tags using unpkg or jsdelivr. It is recommended to replace @latest with a specific version to ensure stability.

    <link
      rel="stylesheet"
      href="https://unpkg.com/simplebar@latest/dist/simplebar.css"
    />
    <script src="https://unpkg.com/simplebar@latest/dist/simplebar.min.js"></script>
    <!-- or -->
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/simplebar@latest/dist/simplebar.css"
    />
    <script src="https://cdn.jsdelivr.net/npm/simplebar@latest/dist/simplebar.min.js"></script>
  3. Set up simplebar-vue in a Vue application

    master

    To use SimpleBar in your Vue project, you must register the component and import the required CSS. Ensure you import both the JavaScript component and the simplebar.min.css file.

    import simplebar from 'simplebar-vue';
    import 'simplebar-vue/dist/simplebar.min.css';
    
    export default {
      components: {
        simplebar,
      },
    };
  4. Add Noscript support for SimpleBar

    master

    To ensure elements remain scrollable when JavaScript is disabled, include this <noscript> block in your <head> to restore native scrolling styles.

    <noscript>
      <style>
        [data-simplebar] {
          overflow: auto;
        }
    
        .simplebar-content-wrapper {
          scrollbar-width: auto;
          -ms-overflow-style: auto;
        }
    
        .simplebar-content-wrapper::-webkit-scrollbar, 
        .simplebar-hide-scrollbar::-webkit-scrollbar {
          display: initial;
          width: initial;
          height: initial;
        }
      </style>
    </noscript>