- Plugins
- Scroll Nav
Plugins
Tailwind CSS Scroll Nav
Scroll Nav is a versatile and lightweight JavaScript plugin designed to enhance navigation menus with smooth scrolling capabilities.
Installation
To get started, install Scroll Nav plugin via npm, else you can skip this step if you are already using Preline UI as a package.
npm i @preline/scroll-nav
Basic usage
Prefer to create your own style? Here is a completely unstylized example.
<div data-hs-scroll-nav class="relative px-6">
<button type="button" class="hs-scroll-nav-prev">Previous</button>
<nav class="hs-scroll-nav-body flex flex-nowrap overflow-x-auto snap-x snap-mandatory">
<a class="snap-start" href="#">Electronics</a>
<a class="snap-start" href="#">Clothing</a>
<a class="snap-start" href="#">House & Garden</a>
<a class="snap-start" href="#">Baby Care</a>
<a class="snap-start" href="#">Home appliances</a>
<a class="snap-start" href="#">Sports & Fitness</a>
<a class="snap-start" href="#">Constraction & Renovation</a>
<a class="snap-start" href="#">Food</a>
<a class="snap-start" href="#">Pharmacy</a>
<a class="snap-start" href="#">Pet Products</a>
<a class="snap-start" href="#">Books</a>
<a class="snap-start" href="#">Tourism, fishing, hunting</a>
<a class="snap-start" href="#">Furniture</a>
<a class="snap-start" href="#">Jewelery</a>
<a class="snap-start" href="#">Accessories</a>
<a class="snap-start" href="#">Games & Consoles</a>
<a class="snap-start" href="#">Stationery</a>
<a class="snap-start" href="#">Digital Goods</a>
<a class="snap-start" href="#">Music</a>
</nav>
<button type="button" class="hs-scroll-nav-next">Next</button>
</div>
Methods
The HSScrollNav
object is contained within the global window
object
Destroy instance.
const { element } = HSScrollNav.getInstance('#scroll-nav', true);
const eCommerce = document.querySelector('#e-commerce-link');
element.goTo(eCommerce, () => {
console.log('Scrolled!');
});
Demo examples
Looking for prebuilt UI components based on the Tailwind CSS? Preline UI packs hundreds of component examples for all your website needs.
Check out Preline UI Components