Create Elementor Tabs With Horizontal Scroll For Mobile Users

Create Elementor Tabs With Horizontal Scroll For Mobile Users

Check out our CSS Course, made especially for Elementor users.

Table of Contents

In this tutorial, I will show you how to add horizontal scroll to the Elementor Tabs titles. Works great on mobile, and works for desktop as well if you need it there too!

Facebook apps uses this, Uber Eats, YouTube, why not you? Elementor tabs mobile scrollable title!

Here is what we will create. Note that on an actual mobile, that thick scroll bar won't show up.

You can also visit this url from your mobile for a better preview.

To begin with, create your tabs Element the way you want it

Here, we are using the one that comes by default with Elementor. This works with both the old tab element, and the new one that allows adding element directly within its content.

Then, add an HTML element on your page, and add this code in it

The HTML element can be anywhere on the page.

Create Elementor Tabs With Horizontal Scroll For Mobile Users 1

Copy paste the following code in it to make the tabs horizontally scrollable.

Here is the code for the old tabs element:

<style>

.elementor-tab-title.elementor-tab-mobile-title {
display: none;
}

.elementor-tab-title:nth-child(odd) {
background-color: teal;
}

.elementor-tab-title:nth-child(even) {
background-color: crimson;
}

.elementor .elementor-element .elementor-tabs-wrapper {
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
margin-right: -10px;
}

.elementor-tabs-wrapper::-webkit-scrollbar {
height: 0;
}

.elementor-tab-title {
flex: 0 0 auto;
}

.elementor-tab-desktop-title.elementor-active:before,
.elementor-tab-desktop-title.elementor-active:after {
width: 0!important;
}

/* Desktop scroll bar styling */
@media (min-width:1025px){

.elementor-tabs-wrapper::-webkit-scrollbar-track {
background-color: #b6b6b6;
}
.elementor-tabs-wrapper::-webkit-scrollbar {
height: 8px;
background-color: #F4f4f4;
}
.elementor-tabs-wrapper::-webkit-scrollbar-thumb {
background-color: #0000008f;
}
}
</style>
<script>
/* Code from https://element.how/elementor-tabs-mobile-scroll/
* Version 1.0
* Copyright 2022 Maxime Desrosiers
*/
document.addEventListener('DOMContentLoaded',function(){

let scrollableNavigations = document.querySelectorAll('.e-n-tabs-heading');

scrollableNavigations.forEach((scrollableNavigation, index) => {
let navigationItems = scrollableNavigation.querySelectorAll('.e-n-tab-title');

scrollableNavigation.style.scrollBehavior = "smooth";

navigationItems.forEach((navigationItem,i) => {
let scrollToPosition = (navigationItem.getBoundingClientRect().left + navigationItem.offsetWidth/2) - (window.innerWidth/2);
navigationItem.addEventListener('click',function(event){
scrollableNavigation.scrollTo(scrollToPosition, 0);
});
});
});

});
</script>

Here is the code for the new tabs element:

<style>

.e-n-tabs-heading.e-n-tabs-heading.e-n-tabs-heading.e-n-tabs-heading {
overflow-x: auto; /* enable horizontal scrolling */
display: flex;
flex-wrap: nowrap;
justify-content: start;
padding-bottom: 10px;
}

.e-n-tabs-heading > .e-n-tab-title{
white-space: nowrap; /* optional, prevent tabs title from breaking into 2 lines */
}

.e-n-tabs-content .e-n-tab-title {
display: none; /* don't display mobile tab titles */
}

/* Desktop scroll bar styling, if you want the horizontal scroll on desktop as well */
@media (min-width:1025px){
.e-n-tabs-heading::-webkit-scrollbar-track {
background-color: #dedede;
}
.e-n-tabs-heading::-webkit-scrollbar {
height: 8px;
}
.e-n-tabs-heading::-webkit-scrollbar-thumb {
background-color: #aeaeae;
}
}

</style>
<script>
/* Code from https://element.how/elementor-tabs-mobile-scroll/
* Version 1.0
* Copyright 2022 Maxime Desrosiers
*/
document.addEventListener('DOMContentLoaded',function(){

let scrollableNavigations = document.querySelectorAll('.e-n-tabs-heading');

scrollableNavigations.forEach((scrollableNavigation, index) => {
let navigationItems = scrollableNavigation.querySelectorAll('.e-n-tab-title');

scrollableNavigation.style.scrollBehavior = "smooth";

navigationItems.forEach((navigationItem,i) => {
let scrollToPosition = (navigationItem.getBoundingClientRect().left + navigationItem.offsetWidth/2) - (window.innerWidth/2);
navigationItem.addEventListener('click',function(event){
scrollableNavigation.scrollTo(scrollToPosition, 0);
});
});
});

});
</script>

Finally, enjoy your new auto centering, horizontally scrollable tabs element!

That's right, the code also includes JavaScript that will automatically center the active tab!

Cheers!

Element.how also provides premium tutorials showing awesome advanced designs, check them out here.

Looking for something else? Search across 2445 Elements right here:

Checkout the Elementor Addon Finder directly

Comments

56 Responses

  1. Hello, thanks for the code. Is this supposed to allow us to scroll horizontally by finger swipe on mobile? if so, i can't seem to get it to work on my mobile phone (iphone 7plus)

    1. my bad, it actually works. didn't know it was just for the title in the tabs. is there any way i can make this work with the contents in the tabs?

  2. Thats pretty cool. But it seems like its not working if the page is a User restricted Area.
    If i create a new "page" it works fine. On my template sections in the user area it is not working.

  3. Hi Maxime,
    LOVE this tab swipe function but I am having a little trouble with it.
    On one site is working perfectly and then on another, the swipe function is jittery and unresponsive.

    Have you encountered this before?

    1. PS - It works fine on computer in browser Dev (responsive) mode but not on my mobile. And also checked a few browsers on my mobile to rule out browser problem. Also checked on another mobile and same issue.

      1. Seems to work fine for me... Did you test my demo above with your mobile phones?

  4. Hi! I need to be able to scroll on desktop too, since there's too many tabs for the viewport. Is there a way to use this with a scrollbar or something like that?

  5. Thank you very much for these great tutorials,
    Can you provide the code for Crocoblock JetTabs?
    I tried to make it myself, but I couldnt 🙂

    1. Here it is:

      .elementor .elementor-element .jet-tabs__control-wrapper {
         display: flex;
         flex-wrap: nowrap;
         overflow-x: auto;
         -webkit-overflow-scrolling: touch;
         -ms-overflow-style: -ms-autohiding-scrollbar;
         margin-right: -10px;
         justify-content:start!important;
      }
      .elementor .elementor-element .jet-tabs__control-wrapper::-webkit-scrollbar {
      		height: 0;
      }
      .elementor .elementor-element .jet-tabs__control-wrapper > div {
          min-width:140px; /* adjust to fit your needs */
      }
      
      .jet-tabs.jet-tabs-position-top {
         display:block;
      }
      
      1. Oh how happy I was to find this comment, I have been trying to adapt the code for hours. Thank you for sharing this!!!

  6. Thank you very much for your code.
    But, I have problem with tablet viewport @media (max-width: 1024px). The scroll tabs limited slide from left tabs, so some of tabs title are not visible.
    May I know how to fix that?

    1. UX UI isn't great on desktop if you add this. There will be an ugly scroll bar... This is really more for Mobile users.

    1. Hey Francis!

      try this, under Advanced > custom CSS

      selector .elementor-tabs-wrapper {
      overflow: hidden;
      max-width: 100vw;
      }

      1. Fixed it without the code 🙂

        Layout/Items/Wrap selected no wrap.

        Thank you for your help.

    1. Use this code for that:

      @media (max-width:1024px){
      
      .elementor-tab-title.elementor-tab-mobile-title {
         display: none;
      }
      
      .elementor-tab-title:nth-child(odd) {
         background-color: teal;
      }
      
      .elementor-tab-title:nth-child(even) {
         background-color: crimson;
      }
      
      .elementor .elementor-element .elementor-tabs-wrapper {
         display: flex;
         flex-wrap: nowrap;
         overflow-x: auto;
         -webkit-overflow-scrolling: touch;
         -ms-overflow-style: -ms-autohiding-scrollbar;
         margin-right: -10px;
      }
      
      .elementor-tabs-wrapper::-webkit-scrollbar {
      		height: 0;
      }
      
      .elementor-tab-title {
         flex: 0 0 auto;
      }
      
      .elementor-tab-desktop-title.elementor-active:before,
      .elementor-tab-desktop-title.elementor-active:after {
         width: 0!important;
      }
      
      }
      
      
    1. Greetings!

      Not as it is no. Similar CSS will work for elements, but not exactly the same...

      Try:

      selector {
      max-width:100vw;
      overflow-x:auto;
      }

      1. Greetings!

        I updated the code, should be working now!

        Cheers!

  7. Is there a limit to how many tabs can be used? I have 14 tabs and oddly 7 are visible in mobile portrait view and 9 are visible in mobile landscape view. I am using latest version of Elementor Pro with containers. Please advise. Thank you.

    1. Hey Jeffrey!

      What version of the code are you using? What result would you expect that you don't have (ie, what does "doesn't work" mean?)

      Thanks!

      1. It's the updated code. If you nest 2 tab elements, the 2nd tab instance doesn't display. The fields show up, but the tabs are not displaying and don't function.

Leave a Reply

BRAND NEW

CSS Course For Elementor Users

Become a CSS ninja and design exciting, quality websites that stand out in the crowd.