Files
2023-03-09 00:48:19 +01:00

323 lines
76 KiB
HTML

<!DOCTYPE html><html lang="en" data-overlayscrollbars-initialize=""><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>OverlayScrollbars</title><meta name="description" content="A javascript scrollbar plugin that hides native scrollbars, provides custom styleable overlay scrollbars and keeps the native functionality and feeling."/><link rel="icon" href="/OverlayScrollbars/_next/static/media/favicon.7b344e85.ico"/><link rel="shortcut icon" type="image/x-icon" href="/OverlayScrollbars/_next/static/media/favicon.7b344e85.ico"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="theme-color" content="#36befd"/><meta name="msapplication-TileColor" content="#36befd"/><meta name="msapplication-navbutton-color" content="#36befd"/><meta name="application-name" content="OverlayScrollbars"/><meta name="msapplication-tooltip" content="OverlayScrollbars"/><meta name="apple-mobile-web-app-title" content="OverlayScrollbars"/><script type="application/ld+json">{"@context":"http://schema.org","@type":"SoftwareSourceCode","url":"https://kingsora.github.io/OverlayScrollbars","name":"OverlayScrollbars","description":"A javascript scrollbar plugin that hides native scrollbars, provides custom styleable overlay scrollbars and keeps the native functionality and feeling.","license":"https://en.wikipedia.org/wiki/MIT_License","keywords":"js,javascript,typescript,overlayscrollbars,overlay,scrollbars,custom,scrollbar,plugin,react,vue,angular,treeshaking","isAccessibleForFree":true,"image":"https://raw.githubusercontent.com/KingSora/OverlayScrollbars/master/logo/logo.png","codeRepository":"https://github.com/KingSora/OverlayScrollbars","runtimePlatform":"browser","maintainer":{"@type":"Person","name":"Rene Haas","additionalName":"KingSora","url":"https://github.com/KingSora"},"programmingLanguage":{"@type":"ComputerLanguage","name":"javascript","alternateName":"js"}}</script><meta name="next-head-count" content="14"/><link rel="preload" href="/OverlayScrollbars/_next/static/css/2edffb4e954af5a3.css" as="style"/><link rel="stylesheet" href="/OverlayScrollbars/_next/static/css/2edffb4e954af5a3.css" data-n-g=""/><link rel="preload" href="/OverlayScrollbars/_next/static/css/054cd89f2e050c9e.css" as="style"/><link rel="stylesheet" href="/OverlayScrollbars/_next/static/css/054cd89f2e050c9e.css" data-n-p=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/OverlayScrollbars/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/OverlayScrollbars/_next/static/chunks/webpack-dd4523633be5c384.js" defer=""></script><script src="/OverlayScrollbars/_next/static/chunks/framework-80c43e603d70cda7.js" defer=""></script><script src="/OverlayScrollbars/_next/static/chunks/main-ea1211b077f8a1ed.js" defer=""></script><script src="/OverlayScrollbars/_next/static/chunks/pages/_app-5ce28d8f4b54a7a6.js" defer=""></script><script src="/OverlayScrollbars/_next/static/chunks/pages/index-79d5f55dc79d656d.js" defer=""></script><script src="/OverlayScrollbars/_next/static/MyU_DR0NDL6t-x0Gm3Atx/_buildManifest.js" defer=""></script><script src="/OverlayScrollbars/_next/static/MyU_DR0NDL6t-x0Gm3Atx/_ssgManifest.js" defer=""></script></head><body data-overlayscrollbars-initialize=""><div id="__next"><div class="font-sans font-normal text-primary-dark"><div class="px-6 sm:container"><div class="mt-8 flex justify-center items-center h-[33vh] min-h-32 max-h-40 xxs:max-h-44"><div class="h-full assets_logo__UC59w"><img src="/OverlayScrollbars/_next/static/media/logo.5dcad24b.svg" class="h-full" alt="OverlayScrollbars Logo" width="200" height="200"/></div></div><h1 class="text-center xxs:text-4xl text-2xl font-bold my-11">Overlay<wbr/>Scrollbars</h1><p class="text-center mx-auto max-w-screen-sm my-11 font-medium">A javascript scrollbar plugin that hides native scrollbars, provides custom styleable overlay scrollbars and keeps the native functionality and feeling.</p><div class="my-6 text-center font-medium text-sm uppercase relative"><span class="p-3 bg-white">used by<div class="absolute block top-1/2 left-1/2 w-[100%] xs:w-[80%] border-t-[1px] border-slate-300 translate-x-[-50%] translate-y-[-50%] z-[-1]"></div></span></div><div data-overlayscrollbars-initialize=""><div><div class="flex justify-center"><div class="inline-flex items-center gap-6 py-6 assets_usedBy__FHTGG"><div class="h-11 px-3 flex-grow flex-shrink-0" style="filter:brightness(0.35)"><img class="h-full" src="/OverlayScrollbars/_next/static/media/spotify-logo.0dffbf88.svg" alt=""/></div><div class="h-11 px-3 py-1.5 flex-grow flex-shrink-0"><img class="h-full" src="/OverlayScrollbars/_next/static/media/storybook-logo.e62f5bdf.svg" alt=""/></div><div class="h-11 p-3 flex-grow flex-shrink-0"><img class="h-full" src="/OverlayScrollbars/_next/static/media/adminlte-logo.22257d89.png" alt=""/></div></div></div></div></div><div class="my-6 text-center font-medium text-sm uppercase relative"><span class="p-3 bg-white"><a href="https://github.com/KingSora/OverlayScrollbars" target="_blank" rel="noreferrer"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" class="default:fill-current inline-block w-11 hover:scale-110 text-primary-dark hover:text-primary-blue1 active:text-primary-blue2 transition-transformColor ease-in-out duration-300"><use href="/OverlayScrollbars/_next/static/media/github.f9873dbb.svg#github"></use></svg><span class="sr-only">OverlayScrollbars on Github</span></a><div class="absolute block top-1/2 left-1/2 w-[100%] xs:w-[80%] border-t-[1px] border-slate-300 translate-x-[-50%] translate-y-[-50%] z-[-1]"></div></span></div><p class="text-center text-sm text-primary-gray2 mx-auto max-w-screen-sm my-11 font-medium">This page is a work in progress. For now refer to the TypeScript definitions for a more detailed documentation.<br/>Looking for the v1 docs?<!-- --> <a href="v1" class="text-primary-blue2 underline">Follow this link</a>.</p><div class="mx-auto flex sm:flex-row justify-center gap-2 items-center flex-wrap"><a href="https://www.npmjs.com/package/overlayscrollbars"><img class="min-h-[20px]" src="https://img.shields.io/npm/dm/overlayscrollbars.svg?style=flat-square" alt="Downloads"/></a><a href="https://www.npmjs.com/package/overlayscrollbars"><img class="min-h-[20px]" src="https://img.shields.io/npm/v/overlayscrollbars.svg?style=flat-square" alt="Version"/></a><a href="https://github.com/KingSora/OverlayScrollbars/blob/master/LICENSE"><img class="min-h-[20px]" src="https://img.shields.io/github/license/kingsora/overlayscrollbars.svg?style=flat-square" alt="License"/></a><a href="https://app.codecov.io/gh/KingSora/OverlayScrollbars"><img class="min-h-[20px]" src="https://img.shields.io/codecov/c/github/KingSora/OverlayScrollbars?style=flat-square" alt="Code Coverage"/></a><a href="https://bundlephobia.com/package/overlayscrollbars"><img class="min-h-[20px]" src="https://img.shields.io/bundlephobia/minzip/overlayscrollbars?label=max.%20bundle%20size&amp;style=flat-square" alt="Max. Bundle Size"/></a></div><div class="mt-11 prose prose-primary mx-auto pb-32"><h2>Why</h2>
<p>I created this plugin because I hate ugly and space consuming scrollbars. Similar plugins haven&#x27;t met my requirements in terms of features, quality, simplicity, license or browser support.</p>
<h2>Goals &amp; Features</h2>
<ul>
<li>Simple, powerful and well documented API</li>
<li>High browser compatibility - <strong>Firefox 59+</strong>, <strong>Chrome 55+</strong>, <strong>Opera 42+</strong>, <strong>Edge 12+</strong>, <strong>Safari 10+</strong> and <strong>IE 11</strong></li>
<li>Can be run on the server - <strong>SSR</strong>, <strong>SSG</strong> and <strong>ISR</strong> support</li>
<li>Tested on various devices - <strong>Mobile</strong>, <strong>Desktop</strong> and <strong>Tablet</strong></li>
<li>Tested with various (and mixed) inputs - <strong>Mouse</strong>, <strong>touch</strong> and <strong>pen</strong></li>
<li><strong>Treeshaking</strong> - bundle only what you really need</li>
<li>Automatic update detection - <strong>no polling</strong></li>
<li>Usage of latest browser features - best <strong>performance</strong> in new browsers</li>
<li>Bidirectional - LTR or RTL direction support</li>
<li>Supports usage on the <code>body</code> element</li>
<li>Supports all <strong>virtual scrolling</strong> libraries</li>
<li>Simple and effective scrollbar styling</li>
<li>Highly customizable</li>
<li>TypeScript support - fully written in TypeScript</li>
<li>Dependency free - 100% self written to ensure small size and best functionality</li>
<li>High quality and fully typed framework versions for <a href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-react"><code>react</code></a>, <a href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-vue"><code>vue</code></a>, <a href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-ngx"><code>angular</code></a>, <a href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-svelte"><code>svelte</code></a> and <a href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-solid"><code>solid</code></a>.</li>
</ul>
<h2>Choose your framework</h2>
<p>Additionally to the vanilla JavaScript version you can use the official framework components &amp; utilities:</p>
<div class="flex flex-wrap"><a class="flex-grow-0 flex-shrink-0" href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-react"><img class="h-[80px] mx-1 my-1" src="https://raw.githubusercontent.com/KingSora/OverlayScrollbars/master/packages/overlayscrollbars-react/logo.svg" width="80" height="80" alt="React"/></a><a class="flex-grow-0 flex-shrink-0" href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-vue"><img class="h-[80px] mx-1 my-1" src="https://raw.githubusercontent.com/KingSora/OverlayScrollbars/master/packages/overlayscrollbars-vue/logo.svg" width="80" height="80" alt="Vue"/></a><a class="flex-grow-0 flex-shrink-0" href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-ngx"><img class="h-[80px] mx-1 my-1" src="https://raw.githubusercontent.com/KingSora/OverlayScrollbars/master/packages/overlayscrollbars-ngx/logo.svg" width="80" height="80" alt="Angular"/></a><a class="flex-grow-0 flex-shrink-0" href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-svelte"><img class="h-[80px] mx-1 my-1" src="https://raw.githubusercontent.com/KingSora/OverlayScrollbars/master/packages/overlayscrollbars-svelte/logo.svg" width="80" height="80" alt="Svelte"/></a><a class="flex-grow-0 flex-shrink-0" href="https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-solid"><img class="h-[80px] mx-1 my-1" src="https://raw.githubusercontent.com/KingSora/OverlayScrollbars/master/packages/overlayscrollbars-solid/logo.svg" width="80" height="80" alt="Solid"/></a></div>
<h2>Getting started</h2>
<h3>npm &amp; nodejs</h3>
<p>OverlayScrollbars can be downloaded from <a href="https://www.npmjs.com/package/overlayscrollbars">npm</a> or the package manager of your choice:</p>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="sh" data-theme="default"><span class="line"><span style="color:#657B83">npm install overlayscrollbars</span></span></code></div></pre></div>
<p>After installation it can be imported:</p>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#859900">import</span><span style="color:#657B83"> </span><span style="color:#2AA198">&#x27;overlayscrollbars/overlayscrollbars.css&#x27;</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#859900">import</span><span style="color:#657B83"> { </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">, </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">ScrollbarsHidingPlugin</span><span style="color:#657B83">, </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">SizeObserverPlugin</span><span style="color:#657B83">, </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">ClickScrollPlugin</span><span style="color:#657B83"> </span></span>
<span class="line"><span style="color:#657B83">} </span><span style="color:#859900">from</span><span style="color:#657B83"> </span><span style="color:#2AA198">&#x27;overlayscrollbars&#x27;</span><span style="color:#657B83">;</span></span></code></div></pre></div>
<blockquote>
<p><strong>Note</strong>: In older nodejs versions use <code>&#x27;overlayscrollbars/styles/overlayscrollbars.css&#x27;</code> as the import path for the CSS file.</p>
</blockquote>
<h3>Manual download &amp; embedding</h3>
<p>You can use OverlayScrollbars without any bundler or package manager.<br/>
<!-- -->Simply download it from the <a href="https://github.com/KingSora/OverlayScrollbars/releases">Releases</a> or use a <a href="https://cdnjs.com/libraries/overlayscrollbars">CDN</a>.</p>
<ul>
<li>Use the javascript files with the <code>.browser</code> extension.</li>
<li>Use the javascript files with the <code>.es5</code> extension if you need to support older browsers like IE11, otherwise use the <code>.es6</code> files.</li>
<li>For production use the javascript / stylesheet files with the <code>.min</code> extension.</li>
</ul>
<p>Embedd OverlayScrollbars manually in your HTML:</p>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="html" data-theme="default"><span class="line"><span style="color:#93A1A1">&lt;</span><span style="color:#268BD2">link</span><span style="color:#657B83"> </span><span style="color:#93A1A1">type</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;text/css&quot;</span><span style="color:#657B83"> </span><span style="color:#93A1A1">href</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;path/to/overlayscrollbars.css&quot;</span><span style="color:#657B83"> </span><span style="color:#93A1A1">rel</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;stylesheet&quot;</span><span style="color:#657B83"> </span><span style="color:#93A1A1">/&gt;</span></span>
<span class="line"><span style="color:#93A1A1">&lt;</span><span style="color:#268BD2">script</span><span style="color:#657B83"> </span><span style="color:#93A1A1">type</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;text/javascript&quot;</span><span style="color:#657B83"> </span><span style="color:#93A1A1">src</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;path/to/overlayscrollbars.browser.es.js&quot;</span><span style="color:#657B83"> </span><span style="color:#93A1A1">defer&gt;&lt;/</span><span style="color:#268BD2">script</span><span style="color:#93A1A1">&gt;</span></span></code></div></pre></div>
<p>You can then use the global variable <code>OverlayScrollbarsGlobal</code> to access the api similar to how you can do it in nodejs / modules:</p>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#586E75;font-style:italic">var</span><span style="color:#657B83"> { </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">, </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">ScrollbarsHidingPlugin</span><span style="color:#657B83">, </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">SizeObserverPlugin</span><span style="color:#657B83">, </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">ClickScrollPlugin</span><span style="color:#657B83"> </span></span>
<span class="line"><span style="color:#657B83">} </span><span style="color:#859900">=</span><span style="color:#657B83"> </span><span style="color:#268BD2">OverlayScrollbarsGlobal</span><span style="color:#657B83">;</span></span></code></div></pre></div>
<p>The examples in this documentation will use the <code>import</code> syntax instead of the <code>OverlayScrollbarsGlobal</code> object. Both versions are equivalent though.</p>
<h2>Initialization</h2>
<blockquote>
<p><strong>Note</strong>: During initialization its expected that the <b>CSS file is loaded and parsed</b> by the browser.</p>
</blockquote>
<p>You can initialize either directly with an <code>Element</code> or with an <code>Object</code> where you have more control over the initialization process.</p>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#93A1A1">// simple initialization with an element</span></span>
<span class="line"><span style="color:#586E75;font-style:italic">const</span><span style="color:#657B83"> </span><span style="color:#268BD2">osInstance</span><span style="color:#657B83"> </span><span style="color:#859900">=</span><span style="color:#657B83"> </span><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">(</span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#myElement&#x27;</span><span style="color:#657B83">), {});</span></span></code></div></pre></div>
<h3>Bridging initialization flickering</h3>
<p>If you initialize OverlayScrollbars it needs a few milliseconds to create and append all the elements to the DOM.
While this period the native scrollbars are still visible and are switched out after the initialization is finished. This is perceived as flickering.</p>
<p>To fix this behavior apply the <code>data-overlayscrollbars-initialize</code> attribute to the target element (and <code>html</code> element if the target element is <code>body</code>).</p>
<h3>Initialization with an Object</h3>
<details><summary><p>This is a in depth topic. Click here to read it.</p></summary><br/><blockquote>
<p><strong>Note</strong>: For now please refer to the <b>TypeScript definitions</b> for a more detailed description of all possibilities.</p>
</blockquote><p>The only required field is the <code>target</code> field. This is the field to which the plugin is applied to.<br/>
<!-- -->If you use the object initialization only with the <code>target</code> field, the outcome is equivalent to the element initialization:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#93A1A1">// Both initializations have the same outcome</span></span>
<span class="line"></span>
<span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">(</span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#myElement&#x27;</span><span style="color:#657B83">), {});</span></span>
<span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">({ target: </span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#myElement&#x27;</span><span style="color:#657B83">) }, {});</span></span></code></div></pre></div><p>In the initialization object you can specify how the library is handling generated elements.
For example you can appoint an existing element as the <code>viewport</code> element. Like this the library won&#x27;t generate it but take the specified element instead:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">({ </span></span>
<span class="line"><span style="color:#657B83"> target: </span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#target&#x27;</span><span style="color:#657B83">),</span></span>
<span class="line"><span style="color:#657B83"> elements: {</span></span>
<span class="line"><span style="color:#657B83"> viewport: </span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#viewport&#x27;</span><span style="color:#657B83">),</span></span>
<span class="line"><span style="color:#657B83"> },</span></span>
<span class="line"><span style="color:#657B83">}, {});</span></span></code></div></pre></div><p>This is very useful if you have a fixed DOM structure and don&#x27;t want OverlayScrollbars to generate its own elements. Those cases arise very often when you want an other library to work together with OverlayScrollbars.</p><hr/><p>You can also decide to which element the scrollbars should be applied to:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">({ </span></span>
<span class="line"><span style="color:#657B83"> target: </span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#target&#x27;</span><span style="color:#657B83">),</span></span>
<span class="line"><span style="color:#657B83"> scrollbars: {</span></span>
<span class="line"><span style="color:#657B83"> slot: </span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#target&#x27;</span><span style="color:#657B83">).</span><span style="color:#268BD2">parentElement</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> },</span></span>
<span class="line"><span style="color:#657B83">}, {});</span></span></code></div></pre></div><hr/><p>And last but not least you can decide when the initialization should be canceled:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">({ </span></span>
<span class="line"><span style="color:#657B83"> target: </span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#target&#x27;</span><span style="color:#657B83">),</span></span>
<span class="line"><span style="color:#657B83"> cancel: {</span></span>
<span class="line"><span style="color:#657B83"> nativeScrollbarsOverlaid: </span><span style="color:#B58900">true</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> body: </span><span style="color:#B58900">null</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> }</span></span>
<span class="line"><span style="color:#657B83">}, {});</span></span></code></div></pre></div><p>In the above example the initialization is canceled when the native scrollbars are overlaid or when your target is a <code>body</code> element and the plugin determined that a initialization to the <code>body</code> element would affect native functionality like <code>window.scrollTo</code>.</p></details>
<h2>Options</h2>
<p>You can initialize OverlayScrollbars with an initial set of options, which can be changed at any time with the <code>options</code> method:</p>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">(</span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#myElement&#x27;</span><span style="color:#657B83">), {</span></span>
<span class="line"><span style="color:#657B83"> overflow: {</span></span>
<span class="line"><span style="color:#657B83"> x: </span><span style="color:#2AA198">&#x27;hidden&#x27;</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> },</span></span>
<span class="line"><span style="color:#657B83">});</span></span></code></div></pre></div>
<h3>Options in depth</h3>
<details><summary><p>This is a in depth topic. Click here to read it.</p></summary><br/><p>The default options are:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#586E75;font-style:italic">const</span><span style="color:#657B83"> </span><span style="color:#268BD2">defaultOptions</span><span style="color:#657B83"> </span><span style="color:#859900">=</span><span style="color:#657B83"> {</span></span>
<span class="line"><span style="color:#657B83"> paddingAbsolute: </span><span style="color:#B58900">false</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> showNativeOverlaidScrollbars: </span><span style="color:#B58900">false</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> update: {</span></span>
<span class="line"><span style="color:#657B83"> elementEvents: [[</span><span style="color:#2AA198">&#x27;img&#x27;</span><span style="color:#657B83">, </span><span style="color:#2AA198">&#x27;load&#x27;</span><span style="color:#657B83">]],</span></span>
<span class="line"><span style="color:#657B83"> debounce: [</span><span style="color:#D33682">0</span><span style="color:#657B83">, </span><span style="color:#D33682">33</span><span style="color:#657B83">],</span></span>
<span class="line"><span style="color:#657B83"> attributes: </span><span style="color:#B58900">null</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> ignoreMutation: </span><span style="color:#B58900">null</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> },</span></span>
<span class="line"><span style="color:#657B83"> overflow: {</span></span>
<span class="line"><span style="color:#657B83"> x: </span><span style="color:#2AA198">&#x27;scroll&#x27;</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> y: </span><span style="color:#2AA198">&#x27;scroll&#x27;</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> },</span></span>
<span class="line"><span style="color:#657B83"> scrollbars: {</span></span>
<span class="line"><span style="color:#657B83"> theme: </span><span style="color:#2AA198">&#x27;os-theme-dark&#x27;</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> visibility: </span><span style="color:#2AA198">&#x27;auto&#x27;</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> autoHide: </span><span style="color:#2AA198">&#x27;never&#x27;</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> autoHideDelay: </span><span style="color:#D33682">1300</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> dragScroll: </span><span style="color:#B58900">true</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> clickScroll: </span><span style="color:#B58900">false</span><span style="color:#657B83">,</span></span>
<span class="line"><span style="color:#657B83"> pointers: [</span><span style="color:#2AA198">&#x27;mouse&#x27;</span><span style="color:#657B83">, </span><span style="color:#2AA198">&#x27;touch&#x27;</span><span style="color:#657B83">, </span><span style="color:#2AA198">&#x27;pen&#x27;</span><span style="color:#657B83">],</span></span>
<span class="line"><span style="color:#657B83"> },</span></span>
<span class="line"><span style="color:#657B83">};</span></span></code></div></pre></div><h3><code>paddingAbsolute</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>boolean</code></td><td align="left"><code>false</code></td></tr></tbody></table><p>Indicates whether the padding for the content shall be absolute.</p><h3><code>showNativeOverlaidScrollbars</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>boolean</code></td><td align="left"><code>false</code></td></tr></tbody></table><p>Indicates whether the native overlaid scrollbars shall be visible.</p><h3><code>update.elementEvents</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>Array&lt;[string, string]&gt; | null</code></td><td align="left"><code>[[&#x27;img&#x27;, &#x27;load&#x27;]]</code></td></tr></tbody></table><p>An array of tuples. The first value in the tuple is an <code>selector</code> and the second value are <code>event names</code>. The plugin will update itself if any of the elements with the specified selector will emit any specified event. The default value can be interpreted as &quot;The plugin will update itself if any <code>img</code> element emits an <code>load</code> event.&quot;</p><h3><code>update.debounce</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>[number, number] | number | null</code></td><td align="left"><code>[0, 33]</code></td></tr></tbody></table><blockquote>
<p><strong>Note</strong>: If 0 is used for the timeout, <code>requestAnimationFrame</code> instead of <code>setTimeout</code> is used for the debounce.</p>
</blockquote><p>Debounces the <code>MutationObserver</code> which tracks changes to the content. If a <strong>tuple</strong> is passed, the first value is the timeout and second is the max wait. If only a <strong>number</strong> is passed you specify only the timeout and there is no max wait. With <strong>null</strong> there is no debounce. <strong>Usefull to fine-tune performance.</strong></p><h3><code>update.attributes</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>string[] | null</code></td><td align="left"><code>null</code></td></tr></tbody></table><blockquote>
<p><strong>Note</strong>: There is a base array of attributes that the <code>MutationObserver</code> always observes, even if this option is <code>null</code>.</p>
</blockquote><p>An array of additional attributes that the <code>MutationObserver</code> should observe for the content.</p><h3><code>update.ignoreMutation</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>((mutation) =&gt; any) | null</code></td><td align="left"><code>null</code></td></tr></tbody></table><p>A function which receives a <a href="https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord"><code>MutationRecord</code></a> as an argument. If the function returns a truthy value the mutation will be ignored and the plugin won&#x27;t update. <strong>Usefull to fine-tune performance.</strong></p><h3><code>overflow.x</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>string</code></td><td align="left"><code>&#x27;scroll&#x27;</code></td></tr></tbody></table><blockquote>
<p><strong>Note</strong>: Valid values are: <code>&#x27;hidden&#x27;</code>, <code>&#x27;scroll&#x27;</code>, <code>&#x27;visible&#x27;</code>, <code>&#x27;visible-hidden&#x27;</code> and <code>&#x27;visible-scroll&#x27;</code>.</p>
</blockquote><p>The overflow behavior for the horizontal (x) axis.</p><h3><code>overflow.y</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>string</code></td><td align="left"><code>&#x27;scroll&#x27;</code></td></tr></tbody></table><blockquote>
<p><strong>Note</strong>: Valid values are: <code>&#x27;hidden&#x27;</code>, <code>&#x27;scroll&#x27;</code>, <code>&#x27;visible&#x27;</code>, <code>&#x27;visible-hidden&#x27;</code> and <code>&#x27;visible-scroll&#x27;</code>.</p>
</blockquote><p>The overflow behavior for the vertical (y) axis.</p><h3><code>scrollbars.theme</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>string | null</code></td><td align="left"><code>&#x27;os-theme-dark&#x27;</code></td></tr></tbody></table><p>Applies the specified theme (classname) to the scrollbars.</p><h3><code>scrollbars.visibility</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>string</code></td><td align="left"><code>&#x27;auto&#x27;</code></td></tr></tbody></table><blockquote>
<p><strong>Note</strong>: Valid values are: <code>&#x27;visible&#x27;</code>, <code>&#x27;hidden&#x27;</code>, and <code>&#x27;auto&#x27;</code>.</p>
</blockquote><p>The base visibility of the scrollbars.</p><h3><code>scrollbars.autoHide</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>string</code></td><td align="left"><code>&#x27;never&#x27;</code></td></tr></tbody></table><blockquote>
<p><strong>Note</strong>: Valid values are: <code>&#x27;never&#x27;</code>, <code>&#x27;scroll&#x27;</code>, <code>&#x27;leave&#x27;</code> and <code>&#x27;move&#x27;</code>.</p>
</blockquote><p>The possibility to hide visible scrollbars automatically after a certain user action.</p><h3><code>scrollbars.autoHideDelay</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>number</code></td><td align="left"><code>1300</code></td></tr></tbody></table><p>The delay in milliseconds before the scrollbars are hidden automatically.</p><h3><code>scrollbars.dragScroll</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>boolean</code></td><td align="left"><code>true</code></td></tr></tbody></table><p>Indicates whether you can drag the scrollbar handles for scrolling.</p><h3><code>scrollbars.clickScroll</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>boolean</code></td><td align="left"><code>false</code></td></tr></tbody></table><blockquote>
<p><strong>Note</strong>: This options requires the <strong>ClickScrollPlugin</strong> to work.</p>
</blockquote><p>Indicates whether you can click on the scrollbar track for scrolling.</p><h3><code>scrollbars.pointers</code></h3><table><thead><tr><th align="left">type</th><th align="left">default</th></tr></thead><tbody><tr><td align="left"><code>string[] | null</code></td><td align="left"><code>[&#x27;mouse&#x27;, &#x27;touch&#x27;, &#x27;pen&#x27;]</code></td></tr></tbody></table><p>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType"><code>PointerTypes</code></a> the plugin should react to.</p></details>
<h2>Events</h2>
<p>You can initialize OverlayScrollbars with an initial set of events, which can be managed at any time with the <code>on</code> and <code>off</code> methods:</p>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">(</span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">querySelector</span><span style="color:#657B83">(</span><span style="color:#2AA198">&#x27;#myElement&#x27;</span><span style="color:#657B83">), {}, {</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">updated</span><span style="color:#657B83">(osInstance, onUpdatedArgs) {</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// ...</span></span>
<span class="line"><span style="color:#657B83"> }</span></span>
<span class="line"><span style="color:#657B83">});</span></span></code></div></pre></div>
<h3>Events in depth</h3>
<details><summary><p>This is a in depth topic. Click here to read it.</p></summary><br/><blockquote>
<p><strong>Note</strong>: Every event receives the <code>instance</code> from which it was invoked as the first argument. Always.</p>
</blockquote><h3><code>initialized</code></h3><table><thead><tr><th align="left">arguments</th><th align="left">description</th></tr></thead><tbody><tr><td align="left"><code>instance</code></td><td align="left">The instance which invoked the event.</td></tr></tbody></table><p>Is invoked after all generated elements, observers and events were appended to the DOM.</p><h3><code>updated</code></h3><table><thead><tr><th align="left">arguments</th><th align="left">description</th></tr></thead><tbody><tr><td align="left"><code>instance</code></td><td align="left">The instance which invoked the event.</td></tr><tr><td align="left"><code>onUpdatedArgs</code></td><td align="left">An <code>object</code> which describes the update in detail.</td></tr></tbody></table><blockquote>
<p><strong>Note</strong>: If an update was triggered but nothing changed, the event won&#x27;t be invoked.</p>
</blockquote><p>Is invoked after the instace was updated.</p><h3><code>destroyed</code></h3><table><thead><tr><th align="left">arguments</th><th align="left">description</th></tr></thead><tbody><tr><td align="left"><code>instance</code></td><td align="left">The instance which invoked the event.</td></tr><tr><td align="left"><code>canceled</code></td><td align="left">An <code>boolean</code> which indicates whether the initialization was canceled and thus destroyed.</td></tr></tbody></table><p>Is invoked after all generated elements, observers and events were removed from the DOM.</p><h3><code>scroll</code></h3><table><thead><tr><th align="left">arguments</th><th align="left">description</th></tr></thead><tbody><tr><td align="left"><code>instance</code></td><td align="left">The instance which invoked the event.</td></tr><tr><td align="left"><code>event</code></td><td align="left">The original <code>event</code> argument of the DOM event.</td></tr></tbody></table><p>Is invoked by scrolling the viewport.</p></details>
<h2>Instance</h2>
<blockquote>
<p><strong>Note</strong>: For now please refer to the <b>TypeScript definitions</b> for a more detailed description.</p>
</blockquote>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="ts" data-theme="default"><span class="line"><span style="color:#586E75;font-style:italic">interface</span><span style="color:#657B83"> </span><span style="color:#CB4B16">OverlayScrollbars</span><span style="color:#657B83"> {</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">options</span><span style="color:#657B83">()</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">Options</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">options</span><span style="color:#657B83">(newOptions</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">PartialOptions</span><span style="color:#657B83">, pure</span><span style="color:#859900">?:</span><span style="color:#657B83"> </span><span style="color:#859900">boolean</span><span style="color:#657B83">)</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">Options</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">on</span><span style="color:#657B83">(eventListeners</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListeners</span><span style="color:#657B83">, pure</span><span style="color:#859900">?:</span><span style="color:#657B83"> </span><span style="color:#859900">boolean</span><span style="color:#657B83">)</span><span style="color:#859900">:</span><span style="color:#657B83"> () </span><span style="color:#586E75;font-style:italic">=&gt;</span><span style="color:#657B83"> </span><span style="color:#859900">void</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">on</span><span style="color:#657B83">&lt;</span><span style="color:#CB4B16">N</span><span style="color:#657B83"> </span><span style="color:#586E75;font-style:italic">extends</span><span style="color:#657B83"> </span><span style="color:#859900">keyof</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListenerArgs</span><span style="color:#657B83">&gt;(name</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">N</span><span style="color:#657B83">, listener</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListener</span><span style="color:#657B83">&lt;</span><span style="color:#CB4B16">N</span><span style="color:#657B83">&gt;)</span><span style="color:#859900">:</span><span style="color:#657B83"> () </span><span style="color:#586E75;font-style:italic">=&gt;</span><span style="color:#657B83"> </span><span style="color:#859900">void</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">on</span><span style="color:#657B83">&lt;</span><span style="color:#CB4B16">N</span><span style="color:#657B83"> </span><span style="color:#586E75;font-style:italic">extends</span><span style="color:#657B83"> </span><span style="color:#859900">keyof</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListenerArgs</span><span style="color:#657B83">&gt;(name</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">N</span><span style="color:#657B83">, listener</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListener</span><span style="color:#657B83">&lt;</span><span style="color:#CB4B16">N</span><span style="color:#657B83">&gt;[])</span><span style="color:#859900">:</span><span style="color:#657B83"> () </span><span style="color:#586E75;font-style:italic">=&gt;</span><span style="color:#657B83"> </span><span style="color:#859900">void</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">off</span><span style="color:#657B83">&lt;</span><span style="color:#CB4B16">N</span><span style="color:#657B83"> </span><span style="color:#586E75;font-style:italic">extends</span><span style="color:#657B83"> </span><span style="color:#859900">keyof</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListenerArgs</span><span style="color:#657B83">&gt;(name</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">N</span><span style="color:#657B83">, listener</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListener</span><span style="color:#657B83">&lt;</span><span style="color:#CB4B16">N</span><span style="color:#657B83">&gt;)</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#859900">void</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">off</span><span style="color:#657B83">&lt;</span><span style="color:#CB4B16">N</span><span style="color:#657B83"> </span><span style="color:#586E75;font-style:italic">extends</span><span style="color:#657B83"> </span><span style="color:#859900">keyof</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListenerArgs</span><span style="color:#657B83">&gt;(name</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">N</span><span style="color:#657B83">, listener</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListener</span><span style="color:#657B83">&lt;</span><span style="color:#CB4B16">N</span><span style="color:#657B83">&gt;[])</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#859900">void</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">update</span><span style="color:#657B83">(force</span><span style="color:#859900">?:</span><span style="color:#657B83"> </span><span style="color:#859900">boolean</span><span style="color:#657B83">)</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#859900">boolean</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">state</span><span style="color:#657B83">()</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">State</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">elements</span><span style="color:#657B83">()</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">Elements</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">destroy</span><span style="color:#657B83">()</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#859900">void</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83">}</span></span></code></div></pre></div>
<h2>Static Methods</h2>
<blockquote>
<p><strong>Note</strong>: For now please refer to the <b>TypeScript definitions</b> for a more detailed description.</p>
</blockquote>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="ts" data-theme="default"><span class="line"><span style="color:#586E75;font-style:italic">interface</span><span style="color:#657B83"> </span><span style="color:#CB4B16">OverlayScrollbarsStatic</span><span style="color:#657B83"> {</span></span>
<span class="line"><span style="color:#657B83"> (target</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">InitializationTarget</span><span style="color:#657B83">)</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">OverlayScrollbars</span><span style="color:#657B83"> </span><span style="color:#859900">|</span><span style="color:#657B83"> </span><span style="color:#859900">undefined</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> (target</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">InitializationTarget</span><span style="color:#657B83">, options</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">PartialOptions</span><span style="color:#657B83">, eventListeners</span><span style="color:#859900">?:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">EventListeners</span><span style="color:#657B83">)</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">OverlayScrollbars</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">plugin</span><span style="color:#657B83">(plugin</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">Plugin</span><span style="color:#657B83"> </span><span style="color:#859900">|</span><span style="color:#657B83"> </span><span style="color:#CB4B16">Plugin</span><span style="color:#657B83">[])</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#859900">void</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">valid</span><span style="color:#657B83">(osInstance</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#859900">any</span><span style="color:#657B83">)</span><span style="color:#859900">:</span><span style="color:#657B83"> osInstance </span><span style="color:#859900">is</span><span style="color:#657B83"> </span><span style="color:#CB4B16">OverlayScrollbars</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">env</span><span style="color:#657B83">()</span><span style="color:#859900">:</span><span style="color:#657B83"> </span><span style="color:#CB4B16">Environment</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83">}</span></span></code></div></pre></div>
<h2>Styling</h2>
<p>OverlayScrollbars comes with two themes called <code>os-theme-dark</code> and <code>os-theme-light</code>. You can use the <code>scrollbars.theme</code> option to change the theme.</p>
<p>Custom themes can be done in multiple ways. The easiest and fastest is to use the predefined set of <code>CSS Custom Properties</code> aka. CSS variables. In case those aren&#x27;t enought you can add custom class names or add custom styling to the existing class names.</p>
<h3>Styling in depth</h3>
<details><summary><p>This is a in depth topic. Click here to read it.</p></summary><h3>CSS Custom properties</h3><p>OverlayScrollbars provides a set of <code>CSS Custom Properties</code> which makes scrollbar styling easy and fast:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="scss" data-theme="default"><span class="line"><span style="color:#93A1A1">.os-scrollbar</span><span style="color:#657B83"> {</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The size of the scrollbar</span></span>
<span class="line"><span style="color:#657B83"> --os-size: </span><span style="color:#D33682">0</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The axis-perpedicular padding of the scrollbar (horizontal: padding-y, vertical: padding-x)</span></span>
<span class="line"><span style="color:#657B83"> --os-padding-perpendicular: </span><span style="color:#D33682">0</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The axis padding of the scrollbar (horizontal: padding-x, vertical: padding-y)</span></span>
<span class="line"><span style="color:#657B83"> --os-padding-axis: </span><span style="color:#D33682">0</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The border radius of the scrollbar track</span></span>
<span class="line"><span style="color:#657B83"> --os-track-border-radius: </span><span style="color:#D33682">0</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The background of the scrollbar track</span></span>
<span class="line"><span style="color:#657B83"> --os-track-bg: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :hover background of the scrollbar track</span></span>
<span class="line"><span style="color:#657B83"> --os-track-bg-hover: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :active background of the scrollbar track</span></span>
<span class="line"><span style="color:#657B83"> --os-track-bg-active: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The border of the scrollbar track</span></span>
<span class="line"><span style="color:#657B83"> --os-track-border: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :hover background of the scrollbar track</span></span>
<span class="line"><span style="color:#657B83"> --os-track-border-hover: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :active background of the scrollbar track</span></span>
<span class="line"><span style="color:#657B83"> --os-track-border-active: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The border radius of the scrollbar handle</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-border-radius: </span><span style="color:#D33682">0</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The background of the scrollbar handle</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-bg: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :hover background of the scrollbar handle</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-bg-hover: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :active background of the scrollbar handle</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-bg-active: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The border of the scrollbar handle</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-border: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :hover border of the scrollbar handle</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-border-hover: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :active border of the scrollbar handle</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-border-active: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The min size of the scrollbar handle</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-min-size: </span><span style="color:#D33682">33</span><span style="color:#859900">px</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The max size of the scrollbar handle</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-max-size: none;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The axis-perpedicular size of the scrollbar handle (horizontal: height, vertical: width)</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-perpendicular-size: </span><span style="color:#D33682">100</span><span style="color:#859900">%</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :hover axis-perpedicular size of the scrollbar handle (horizontal: height, vertical: width)</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-perpendicular-size-hover: </span><span style="color:#D33682">100</span><span style="color:#859900">%</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// The :active axis-perpedicular size of the scrollbar handle (horizontal: height, vertical: width)</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-perpendicular-size-active: </span><span style="color:#D33682">100</span><span style="color:#859900">%</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">// Increases the interactive area of the scrollbar handle.</span></span>
<span class="line"><span style="color:#657B83"> --os-handle-interactive-area-offset: </span><span style="color:#D33682">0</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83">}</span></span></code></div></pre></div><p>You can alter the properties either for both scrollbars at once or per scrollbar axis. In the example below I&#x27;ve chosen <code>os-theme-custom</code> as the theme name:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="scss" data-theme="default"><span class="line"><span style="color:#93A1A1">// horizontal and vertical scrollbar are 10px </span></span>
<span class="line"><span style="color:#93A1A1">.os-theme-custom</span><span style="color:#657B83"> {</span></span>
<span class="line"><span style="color:#657B83"> --os-size: </span><span style="color:#D33682">10</span><span style="color:#859900">px</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#93A1A1">// horizontal scrollbar is 10px</span></span>
<span class="line"><span style="color:#93A1A1">.os-theme-custom.os-scrollbar-horizontal</span><span style="color:#657B83"> {</span></span>
<span class="line"><span style="color:#657B83"> --os-size: </span><span style="color:#D33682">10</span><span style="color:#859900">px</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83">}</span></span>
<span class="line"><span style="color:#93A1A1">// vertical scrollbar is 20px</span></span>
<span class="line"><span style="color:#93A1A1">.os-theme-custom.os-scrollbar-vertical</span><span style="color:#657B83"> {</span></span>
<span class="line"><span style="color:#657B83"> --os-size: </span><span style="color:#D33682">20</span><span style="color:#859900">px</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83">}</span></span></code></div></pre></div><p>You can then use your theme by assigning it via the <code>scrollbars.theme</code> option:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">(</span><span style="color:#268BD2">document</span><span style="color:#657B83">.</span><span style="color:#268BD2">body</span><span style="color:#657B83">, {</span></span>
<span class="line"><span style="color:#657B83"> scrollbars: {</span></span>
<span class="line"><span style="color:#657B83"> theme: </span><span style="color:#2AA198">&#x27;os-theme-custom&#x27;</span></span>
<span class="line"><span style="color:#657B83"> }</span></span>
<span class="line"><span style="color:#657B83">});</span></span></code></div></pre></div><p>Since scrollbar styles are usually simple, this set of options should be enough to get your desired styling.
In case you need more freedom you can create your own styles by adding styling to the base class names described in the next section.</p><h3>Scrollbars structure and CSS class names</h3><p>The scrollbars HTML markup looks like:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="html" data-theme="default"><span class="line"><span style="color:#93A1A1">&lt;</span><span style="color:#268BD2">div</span><span style="color:#657B83"> </span><span style="color:#93A1A1">class</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;os-scrollbar os-scrollbar-horizontal&quot;</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">&lt;</span><span style="color:#268BD2">div</span><span style="color:#657B83"> </span><span style="color:#93A1A1">class</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;os-scrollbar-track&quot;</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">&lt;</span><span style="color:#268BD2">div</span><span style="color:#657B83"> </span><span style="color:#93A1A1">class</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;os-scrollbar-handle&quot;</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">&lt;/</span><span style="color:#268BD2">div</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">&lt;/</span><span style="color:#268BD2">div</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#93A1A1">&lt;/</span><span style="color:#268BD2">div</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#93A1A1">&lt;</span><span style="color:#268BD2">div</span><span style="color:#657B83"> </span><span style="color:#93A1A1">class</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;os-scrollbar os-scrollbar-vertical&quot;</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">&lt;</span><span style="color:#268BD2">div</span><span style="color:#657B83"> </span><span style="color:#93A1A1">class</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;os-scrollbar-track&quot;</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">&lt;</span><span style="color:#268BD2">div</span><span style="color:#657B83"> </span><span style="color:#93A1A1">class</span><span style="color:#657B83">=</span><span style="color:#2AA198">&quot;os-scrollbar-handle&quot;</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">&lt;/</span><span style="color:#268BD2">div</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#93A1A1">&lt;/</span><span style="color:#268BD2">div</span><span style="color:#93A1A1">&gt;</span></span>
<span class="line"><span style="color:#93A1A1">&lt;/</span><span style="color:#268BD2">div</span><span style="color:#93A1A1">&gt;</span></span></code></div></pre></div><p>The class names are simplified, in a real application the <code>.os-scrollbar</code> element can have additional class names which modify the appearance (mostly visibility and alignment).</p><p>Below is a list of the most important class names you will encounter:</p><table><thead><tr><th align="left">CSS class name</th><th align="left">description</th></tr></thead><tbody><tr><td align="left"><code>.os-scrollbar</code></td><td align="left">The root element of a scrollbar.</td></tr><tr><td align="left"><code>.os-scrollbar-rtl</code></td><td align="left">Indicates a <code>RTL</code> direction of the host element the scrollbar belongs to.</td></tr><tr><td align="left"><code>.os-scrollbar-horizontal</code></td><td align="left">The root element of a horizontal scrollbar.</td></tr><tr><td align="left"><code>.os-scrollbar-vertical</code></td><td align="left">The root element of a vertical scrollbar.</td></tr><tr><td align="left"><code>.os-scrollbar-handle-interactive</code></td><td align="left">Indicates that the handle inside the scrollbar is interactive (<code>scrollbars.dragScroll</code> is <code>true</code>).</td></tr><tr><td align="left"><code>.os-scrollbar-track-interactive</code></td><td align="left">Indicates that the track inside the scrollbar is interactive (<code>scrollbars.clickScroll</code> is <code>true</code>).</td></tr><tr><td align="left"><code>.os-scrollbar-track</code></td><td align="left">The track element. This is the track of the nested handle element. If <code>scrollbars.clickScroll</code> is <code>true</code> this is the element users can click to change the scroll offset.</td></tr><tr><td align="left"><code>.os-scrollbar-handle</code></td><td align="left">The handle element. If <code>scrollbars.dragScroll</code> is <code>true</code> this is the handle users can drag to change the scroll offset.</td></tr></tbody></table><p>If you create your own theme, please only use the classes listed above. All other classes are modifier classes used to change visibility, alignment and pointer-events of the scrollbars.</p><h3>Gotchas</h3><p>Its important that the chosen theme class name in your CSS file matches the assigned theme name in the options. If the CSS class name is <code>.my-theme</code> the <code>scrollbars.theme</code> has to be <code>&#x27;my-theme&#x27;</code>.</p><p>Please be aware of your stack. <code>css-modules</code> for example will alter your class names to prevent naming collisions. Always double check if your CSS is really what you expect it to be.</p></details>
<h2>Plugins</h2>
<p>Everything thats considered not core functionality or old browser compatibility is exposed via a plugin. This is done because all unused plugins are treeshaken and thus won&#x27;t end up in your final bundle. OverlayScrollbars comes with the following plugins:</p>
<ul>
<li><strong>ScrollbarsHidingPlugin</strong>: Is needed for old browsers which aren&#x27;t supporting native scrollbar styling features. <a href="https://caniuse.com/?search=scrollbar%20styling">You can find the list of browsers where you need this plugin here</a> (note that even though <code>iOS Safari &gt;= 14</code> is marked as unsupported you only need this plugin for <code>iOS &lt; 7.1</code>).</li>
<li><strong>SizeObserverPlugin</strong>: Is needed for old browsers which aren&#x27;t supporting the <code>ResizeObserver</code> api. <a href="https://caniuse.com/?search=ResizeObserver">You can find the list of browsers where you need this plugin here</a></li>
<li><strong>ClickScrollPlugin</strong>: If you want to use the option <code>scrollbars: { clickScroll: true }</code>.</li>
</ul>
<h3>Consuming Plugins</h3>
<p>Plugins are consumed like:</p>
<div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="ts" data-theme="default"><span class="line"><span style="color:#859900">import</span><span style="color:#657B83"> { </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">, </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">ScrollbarsHidingPlugin</span><span style="color:#657B83">, </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">SizeObserverPlugin</span><span style="color:#657B83">, </span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#268BD2">ClickScrollPlugin</span><span style="color:#657B83"> </span></span>
<span class="line"><span style="color:#657B83">} </span><span style="color:#859900">from</span><span style="color:#657B83"> </span><span style="color:#2AA198">&#x27;overlayscrollbars&#x27;</span><span style="color:#657B83">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#93A1A1">// single plugin</span></span>
<span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">.</span><span style="color:#268BD2">plugin</span><span style="color:#657B83">(</span><span style="color:#268BD2">ScrollbarsHidingPlugin</span><span style="color:#657B83">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#93A1A1">// multiple plugins</span></span>
<span class="line"><span style="color:#268BD2">OverlayScrollbars</span><span style="color:#657B83">.</span><span style="color:#268BD2">plugin</span><span style="color:#657B83">([</span><span style="color:#268BD2">SizeObserverPlugin</span><span style="color:#657B83">, </span><span style="color:#268BD2">ClickScrollPlugin</span><span style="color:#657B83">]);</span></span></code></div></pre></div>
<h3>Writing Plugins</h3>
<blockquote>
<p><strong>Note</strong>: For now please refer to the <b>TypeScript definitions</b> for a more detailed description.</p>
</blockquote>
<p>You can write and publish your own Plugins. This section is a work in progress.</p>
<h2>FAQ</h2>
<details><summary><p>How do I <code>get / set</code> the <code>scroll position</code> of an element I applied the OverlayScrollbars to?</p></summary><br/><p>If you applied <code>OverlayScrollbars</code> to the <code>body</code> element you can use <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX"><code>window.scrollX</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY"><code>window.scrollY</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll"><code>window.scroll</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo"><code>window.scrollTo</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy"><code>window.scrollBy</code></a> or any other native api.</p><p>If the plugin was applied to any other element you have to get the <code>viewport</code> element with the <code>instance.elements()</code> function first. With this element you can use <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop"><code>element.scrollTop</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft"><code>element.scrollLeft</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll"><code>element.scroll</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo"><code>element.scrollTo</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollBy"><code>element.scrollBy</code></a> or any other native api.</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="js" data-theme="default"><span class="line"><span style="color:#586E75;font-style:italic">const</span><span style="color:#657B83"> { </span><span style="color:#268BD2">viewport</span><span style="color:#657B83"> } </span><span style="color:#859900">=</span><span style="color:#657B83"> </span><span style="color:#268BD2">osInstance</span><span style="color:#657B83">.</span><span style="color:#268BD2">elements</span><span style="color:#657B83">();</span></span>
<span class="line"><span style="color:#586E75;font-style:italic">const</span><span style="color:#657B83"> { </span><span style="color:#268BD2">scrollLeft</span><span style="color:#657B83">, </span><span style="color:#268BD2">scrollTop</span><span style="color:#657B83"> } </span><span style="color:#859900">=</span><span style="color:#657B83"> </span><span style="color:#268BD2">viewport</span><span style="color:#657B83">; </span><span style="color:#93A1A1">// get scroll offset</span></span>
<span class="line"><span style="color:#268BD2">viewport</span><span style="color:#657B83">.</span><span style="color:#268BD2">scrollTo</span><span style="color:#657B83">({ top: </span><span style="color:#D33682">0</span><span style="color:#657B83"> }); </span><span style="color:#93A1A1">// set scroll offset</span></span></code></div></pre></div></details>
<details><summary><p>Is it possible to <code>limit / adjust the scrollbar handle length</code>?</p></summary><br/><p>You can adjust a scrollbars handle length by setting a <code>min-width / min-height</code> and <code>max-width / max-height</code> style:</p><div data-rehype-pretty-code-fragment=""><pre data-overlayscrollbars-initialize=""><div><code data-language="css" data-theme="default"><span class="line"><span style="color:#93A1A1">/* horizontal boundaries */</span></span>
<span class="line"><span style="color:#93A1A1">.os-scrollbar-horizontal</span><span style="color:#657B83"> </span><span style="color:#93A1A1">.os-scrollbar-handle</span><span style="color:#657B83"> {</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#859900">min-width</span><span style="color:#657B83">: </span><span style="color:#D33682">50</span><span style="color:#859900">px</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#859900">max-width</span><span style="color:#657B83">: </span><span style="color:#D33682">200</span><span style="color:#859900">px</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83">}</span></span>
<span class="line"><span style="color:#93A1A1">/* vertical boundaries */</span></span>
<span class="line"><span style="color:#93A1A1">.os-scrollbar-vertical</span><span style="color:#657B83"> </span><span style="color:#93A1A1">.os-scrollbar-handle</span><span style="color:#657B83"> {</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#859900">min-height</span><span style="color:#657B83">: </span><span style="color:#D33682">40</span><span style="color:#859900">px</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83"> </span><span style="color:#859900">max-height</span><span style="color:#657B83">: </span><span style="color:#D33682">40</span><span style="color:#859900">px</span><span style="color:#657B83">;</span></span>
<span class="line"><span style="color:#657B83">}</span></span></code></div></pre></div><p>You can assign the same value to both properties to force the scrollbar to be always the same size.<br/>
<!-- -->Setting the <code>width</code> and <code>height</code> properties won&#x27;t work since those are set by the plugin automatically.</p></details>
<h2>Feature comparison to <code>v1</code></h2>
<ul>
<li>The <code>scroll</code> function is missing. Planned as a <code>plugin</code>. (WIP)</li>
<li>Initialization to the <code>textarea</code> element isn&#x27;t supported yet. Planned as a <code>plugin</code>. (WIP)</li>
</ul>
<h2>Future Plans</h2>
<ul>
<li>Provide plugin based support for missing features. (treeshakeable)</li>
<li>Frequent updates in terms of bug-fixes and enhancements. (always use latest browser features)</li>
<li>Improve tests. (unit &amp; browser tests)</li>
</ul>
<h2>License</h2>
<p>MIT</p></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"MyU_DR0NDL6t-x0Gm3Atx","assetPrefix":"/OverlayScrollbars","nextExport":true,"autoExport":true,"isFallback":false,"scriptLoader":[]}</script></body></html>