webdevpuneet.com

Bootstrap Horizontal Scrollable Tabs — Free Snippet

Bootstrap Horizontal Scrollable Tabs · Navigation · Plain HTML, CSS & JS · Live preview

CategoryNavigation

Copy & paste

Source Code

<div class="container py-5">
  <div class="bshtabs-wrap">
    <button class="bshtabs-arrow bshtabs-left" id="bshtabsLeft" aria-label="Scroll tabs left">‹</button>
    <ul class="nav nav-tabs bshtabs-nav flex-nowrap" id="bshtabsNav" role="tablist">
      <li class="nav-item"><button class="nav-link active" data-bs-toggle="tab" data-bs-target="#bsh-overview">Overview</button></li>
      <li class="nav-item"><button class="nav-link" data-bs-toggle="tab" data-bs-target="#bsh-specs">Specifications</button></li>
      <li class="nav-item"><button class="nav-link" data-bs-toggle="tab" data-bs-target="#bsh-reviews">Reviews</button></li>
      <li class="nav-item"><button class="nav-link" data-bs-toggle="tab" data-bs-target="#bsh-shipping">Shipping &amp; Returns</button></li>
      <li class="nav-item"><button class="nav-link" data-bs-toggle="tab" data-bs-target="#bsh-warranty">Warranty</button></li>
      <li class="nav-item"><button class="nav-link" data-bs-toggle="tab" data-bs-target="#bsh-faq">FAQ</button></li>
      <li class="nav-item"><button class="nav-link" data-bs-toggle="tab" data-bs-target="#bsh-support">Support</button></li>
    </ul>
    <button class="bshtabs-arrow bshtabs-right" id="bshtabsRight" aria-label="Scroll tabs right">›</button>
  </div>
  <div class="tab-content bshtabs-content p-3">
    <div class="tab-pane fade show active" id="bsh-overview">A compact, precision-milled aluminum stand for any 13–34" monitor.</div>
    <div class="tab-pane fade" id="bsh-specs">Weight capacity: 20kg. Height: 12cm. Material: 6061 aluminum.</div>
    <div class="tab-pane fade" id="bsh-reviews">4.8 out of 5 stars, based on 214 reviews.</div>
    <div class="tab-pane fade" id="bsh-shipping">Free shipping over $50. Returns accepted within 30 days.</div>
    <div class="tab-pane fade" id="bsh-warranty">2-year limited warranty against manufacturing defects.</div>
    <div class="tab-pane fade" id="bsh-faq">Compatible with all standard VESA mounts.</div>
    <div class="tab-pane fade" id="bsh-support">Contact [email protected] for help with your order.</div>
  </div>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month, 7 days free), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Real Bootstrap 5.3 Tab component — pane switching is entirely Bootstrap's own behavior
Horizontally scrollable tab strip for any number of tabs, with the native scrollbar hidden
Left/right arrow buttons scroll the strip smoothly via scrollBy()
Active tab auto-scrolls into view on Bootstrap's own shown.bs.tab event, however it was activated
Works correctly with keyboard tab navigation, not just mouse clicks
No layout limit on tab count — the strip just keeps scrolling

About this UI Snippet

Bootstrap Horizontal Scrollable Tabs — HTML, CSS & JavaScript

Screenshot of the Bootstrap Horizontal Scrollable Tabs snippet rendered live

Seven tab labels — Overview, Specifications, Reviews, Shipping & Returns, Warranty, FAQ, Support — routinely overflow a narrow container. This snippet keeps real Bootstrap 5.3's Tab component doing exactly what it already does well (switching panes via data-bs-toggle="tab") and adds only what it doesn't provide: a horizontally scrollable strip (overflow-x: auto plus flex-nowrap) with two small arrow buttons that call nav.scrollBy() to nudge the strip left or right.

A second, easy-to-miss detail: clicking a tab that's already visible works fine, but a tab reached via keyboard navigation while scrolled out of view wouldn't be. Listening for Bootstrap's own shown.bs.tab event and calling scrollIntoView({ inline: 'center' }) on whichever tab was just activated means the active tab is always visible in the strip, however it was reached.

Step by step

How to Use

  1. 1
    Load the snippetClick the snippet in the sidebar Library tab. The preview loads seven tabs, more than fit in the visible width.
  2. 2
    Click the right arrowThe tab strip smoothly scrolls right, revealing the tabs that were cut off.
  3. 3
    Click a tab near the edgeIt becomes active and scrolls itself into full view if it was partially hidden.
  4. 4
    Add an eighth tabCopy a nav-item/tab-pane pair — it just extends the scrollable strip, no layout changes needed.

Real-world uses

Common Use Cases

Product pages with many detail sections
Overview, Specs, Reviews, Shipping, Warranty, FAQ, Support — a common e-commerce product page tab set that easily exceeds available width.
Learning to extend Bootstrap components without replacing them
A clear example of adding exactly the missing behavior (scroll arrows) on top of a component rather than rebuilding tabs from scratch.
Dashboards with many report or view tabs
Reuse this pattern anywhere a fixed-width tab bar needs to accommodate more tabs than can be shown at once.
Keeping keyboard navigation usable in a scrollable strip
The auto-scroll-into-view behavior matters specifically for visitors tabbing through controls rather than clicking.

Got questions?

Frequently Asked Questions

Real Bootstrap 5.3 — every pane switch is handled by Bootstrap's own Tab component via data-bs-toggle="tab". The only custom code is the horizontal-scroll arrows and the scroll-into-view behavior.

Each calls nav.scrollBy({ left: ±160, behavior: "smooth" }) on the tab strip's container, nudging it by a fixed amount with native smooth scrolling — no custom animation code.

A listener on Bootstrap's own shown.bs.tab event calls scrollIntoView on whichever tab was just activated, so a tab reached via keyboard navigation (or one near the edge) is always brought fully into view.

No — the strip scrolls to accommodate however many nav-items exist; there's no hardcoded tab count anywhere in the logic.

No — scrollbar-width: none and a WebKit scrollbar override hide the native scrollbar, so only the two arrow buttons (and swipe/trackpad scrolling) are visible ways to scroll it.

Yes. While the Bootstrap Horizontal Scrollable Tabs snippet gives you one pattern to copy, the free Responsive Navbar Builder at webdevpuneet.com/navbar-builder/ designs a whole navigation bar: logo, links and dropdown menus, a mobile hamburger menu (dropdown panel, slide-in drawer or full screen) and a scroll effect (sticky, shrink, hide on scroll or transparent). It has six presets, a live preview that runs the real code, and exports HTML + CSS + vanilla JS, React, Tailwind, Vue 3 or Angular — or you can click Fork & Edit to keep editing it in My Code.