This plugin provides dynamic directives that allow you to format scrollbars and scroll thumbs in your projects that use the tailwind framework.
First, you have to download the plugin to your project.
npm i tailwind-modern-scroll -D
You need to add the plugin to the main tailwind configuration file.
your-project/tailwind.config.js
const modernScroll = require( "tailwind-modern-scroll" );
module.exports =
{
// other configs...
plugins:
[
modernScroll,
// ...other plugins
],
// ...other configs
}
If you prefer to use VS Code and installed tailwind intellisense extension our directives will suggest to you in it.
First of all you have to add modern-scroll
base class to your items that have scroll bars. This provides the basic features that meet the minimum requirements for the scrollbar to look modern.
<div class="h-96 w-full overflow-auto modern-scroll"></div>
You can change both the scroll bar background and the scroll thumb background colors with theme colors or direct colors.
<div class="... modern-scroll scroll-sky-100 thumb-[#fc0]"></div>
You can even use opacity modifiers too.
<div class="... scroll-[#000]/20 thumb-[#000]/20"></div>
You can only change scroll wrapper width and not thumb's.
<div class="... scroll-w-10"></div>
We can also change the height of the scroll wrapper.
<div class="... scroll-h-10"></div>
You can specify the minimum and maximum height of the slider.
<div class="... thumb-min-h-10 thumb-max-h-20"></div>
You can round the edges both of the scroll wrapper and the thumb.
<div class="... scroll-round-full thumb-round-full"></div>