Skip to content

Scrollable Tabs for Mobile

Bootstrap 5 tabs that scroll horizontally on small screens, with fade edges, arrow buttons, scroll snapping and the active tab centered automatically.

Also known as: horizontal scrolling tabs, swipeable tabs mobile, tabs with scroll arrows, overflow tabs navigation

Bootstrap 5 Tabs Responsive #mobile #navigation #responsive #scroll #tabs

Scrollable Tabs for Mobile live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

Bootstrap 5 tabs that stay on one line and scroll sideways when there is not enough room, with fade edges, arrow buttons and the active tab centered automatically. Use it for settings pages, dashboards and product pages with many sections, where wrapping tabs would break the layout on phones.

How it works

The root is section.st-tabs, a Bootstrap card with a dark header. The tab list ul.st-nav uses flex-nowrap and width: max-content, so it never wraps. It sits inside .st-scroller, which has overflow-x: auto, a hidden scrollbar and scroll-snap-type: x proximity, so a swipe settles on a tab edge. The scroller is wrapped in .st-bar, whose ::before and ::after pseudo-elements draw gradient fades over the left and right edges. Tabs are regular Bootstrap tab buttons with data-bs-toggle="tab", and the panes live in .st-content.

The script runs on DOMContentLoaded for every .st-tabs. Its update() function compares scrollLeft with the scrollable width and toggles st-has-left and st-has-right on .st-bar, which show the matching fade and the .st-arrow--prev or .st-arrow--next button. It runs on scroll and resize. The center() function scrolls a tab to the middle of the bar; it runs on load for the active tab, on Bootstrap's shown.bs.tab event and on focus. The arrow buttons scroll by 70% of the visible width. When everything fits, no fade or arrow is shown.

Customization

  • --st-active in .st-tabs: changes the color of the active underline, the kicker and the focus ring.
  • --st-bar-bg and --st-bar-text in .st-tabs: recolor the header bar; the fades use the same background automatically.
  • --st-fade in .st-tabs: makes the fade edges wider or narrower and sets the scroll padding.
  • scroll-snap-type: x proximity in .st-scroller: use x mandatory for firmer snapping or remove it.
  • The 0.7 factor in page() in script.js: controls how far one arrow click scrolls.
  • Move the active class and aria-selected="true" to another .st-link (and show active to its pane) to open a different tab first.
  • .st-count: remove the badge or add one to any tab.

Use cases

  • Settings pages: many tabs stay on one line and scroll sideways on phones with fade edges
  • Dashboards: arrow buttons and scroll snapping help users reach tabs that do not fit the screen
  • Product pages: sections like specs, reviews and shipping stay in one row instead of wrapping
  • Mobile-first apps: the active tab is centered automatically when selected or focused

Accessibility

The list has role="tablist" with a label, each button has role="tab", aria-controls and aria-selected, and each pane has role="tabpanel" and aria-labelledby. Bootstrap's tab plugin moves between tabs with the arrow keys, and the focused tab is scrolled into view, so the arrow buttons are aria-hidden and removed from the tab order. Focus is shown with an outline, and transitions are disabled with prefers-reduced-motion: reduce; smooth scrolling then becomes instant.

Usage notes

Requires Bootstrap 5 with its JS bundle and Bootstrap Icons. For several instances on one page, give each one unique tab and pane id values.

Scrollable Tabs for Mobile at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Tabs
License
Free for personal and commercial use

Questions about this template

Can I use the Scrollable Tabs for Mobile code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Scrollable Tabs for Mobile – Bootstrap 5 tabs component screenshot
Scrollable Tabs for Mobile · Bootstrap 5 Tabs

More Tabs

Tabs with Photo Preview Panels – Tailwind CSS tabs preview

Tabs with Photo Preview Panels

Tailwind CSS feature tabs that swap a large photo preview with a caption for each selected tab, with full keyboard support.

Animated Pill Tabs – Pure CSS tabs preview

Animated Pill Tabs

Segmented pill tabs with a sliding, springy background, ARIA tabs keyboard support and fading panels, shown on an analytics card. Pure CSS and vanilla JS.

Vertical Tabs – Bootstrap 5 tabs preview

Vertical Tabs

Bootstrap 5 vertical nav-pills tabs styled as a settings panel with a dark sidebar, icons, fading content panes and a scrollable mobile tab strip.

Underline Tabs – Tailwind CSS tabs preview

Underline Tabs

Accessible Tailwind CSS tabs with a sliding underline indicator, arrow-key and Home/End navigation, count badge and scrollable tab bar on mobile.