Add

Lorem ipsum

Lorem ipsum

Design

1 views

6 min

Automatic tab switching every X seconds in Webflow

Introduction

CSS ClassWebflow ElementRole
tabs-menuTab MenuTab container (1st component)
tab-buttonTab LinkEach tab button (1st component)
tabs-menu-2Tab MenuTab container (2nd component)
tab-button-2Tab LinkEach tab button (2nd component)

Automatically switching tabs every X seconds can serve a few different purposes.

Here are a few reasons you might do it:

  1. User Engagement: Motion or periodic changes can grab users' attention and encourage them to interact more with each tab's content.
  2. Content Highlighting: If you have multiple offers or pieces of information you want to showcase, automatic tab switching can make sure each one gets equal attention from visitors.
  3. Limited Space: If you have limited space on your website to display information, using tabs with automatic switching can be an effective way to show more content in a small area.

‍

good to know

Before we begin, if you'd like to learn more about Gemeos Agency, feel free to book a meeting by clicking here.

‍

Here's how to do it:

‍

Add a tabs element

You can add as many tabs as you want

automatic tab switching Webflow

‍

Add the “tab-button” class to each of your tab links

automatic tab switching Webflow

‍

Add the “tabs-menu” class to your tab menu

automatic tab switching Webflow

‍

Add this custom code to your page before the <body> tag

If you have just one tab element

‍

If you're using multiple tabs elements on your page

Make sure you use:

  • .tabs-menu-2
  • .tab-button-2

for the classes on your second tabs element

 

good to know

Good to know: If you want to add more than two, just duplicate the following code in the previous code and use .tabs-menu-3… and so on.

 

Change the rotation duration

All you need to do is change the delay (in milliseconds) in the code here:

 

‍

good to know

If you want to manage more than two tabs elements, duplicate the tabLoop block and increment the classes (.tabs-menu-3, .tab-button-3…). For a no-jQuery solution, native Webflow interactions or Swiper can replace this script depending on the use case.

Publish and test the result

‍

‍

Published on 10.04.2025

Let’s f*****G GO !!

Ready to launch
Your business?

Alexandre

Max

Enora

Bryan

Cannelle

Tiphaine

You'll :heart: our collaboration...