Tutorials
Last updated on:
Jan 29, 2025

How to create auto-rotating tabs in Webflow: Step-by-step guide

BRIX Templates Logo
Author
BRIX Templates
How to create auto-rotating tabs in Webflow: Step-by-step guide
Table of contents

While Webflow's native Tabs component excels at organizing content, it lacks built-in auto-rotation capabilities. The ability to automatically rotate through tabs can significantly enhance your site's interactivity and user engagement, making it a great feature for showcasing multiple pieces of content efficiently.

This guide will walk you through implementing automatic tab rotation while preserving Webflow's smooth transitions and maintaining full user control, ensuring your tabs function exactly as intended without compromising the platform's native functionality.

When should you use auto tab rotation in Webflow?

  • Multiple hero sections: Transform your hero area into a dynamic showcase that automatically rotates through different value propositions, ensuring visitors catch all your key messages even without interaction.
  • Service showcase: Present your offerings in a space-efficient manner that automatically cycles through each service, giving visitors a comprehensive view of your capabilities without overwhelming them with information all at once.
  • Digestible content segments: Break down complex information into automatically advancing segments, making it easier for visitors to absorb and understand your content while maintaining engagement.

How the Webflow auto-tab rotation script works

The AutoTab script from BRIX Templates is a lightweight yet powerful solution designed specifically for Webflow's native tab system. It brings automatic rotation capabilities while maintaining Webflow's smooth transitions through these key features:

  • Click simulation: The script triggers actual click events instead of direct class manipulation, preserving Webflow's built-in fade transitions exactly as they appear with manual clicks.
  • Auto-pause on hover: When users hover over the tabs, rotation automatically pauses, letting them read content without interruption. Moving the cursor away resumes rotation.
  • Manual click handling: Clicking any tab manually pauses the rotation and resets the timer from that tab, ensuring users can easily interact with specific content when needed.
  • Lightweight implementation: Built with pure JavaScript and no external dependencies, keeping your site fast and reducing potential conflicts with other scripts.
Step by step guide to auto rotate Webflow tabs

1. How to install the tab rotation script in Webflow

  1. Navigate to your Webflow project settings
  2. Access the Custom Code section
  3. Locate the "Footer code" area
Add tab rotation script to Webflow site

Once you are in there, insert the following code:

<script>
/**
 * BRIX AutoTabs for Webflow
 * ----------------------------------------------------------------------------
 * Enhance your Webflow tabs with automatic rotation while maintaining 
 * native transitions and user control. Core features include:
 *
 *  • Per-tab customizable rotation speeds
 *  • Smart hover-pause functionality (enabled by default)
 *  • Preserved Webflow transitions via click simulation
 *  • Simple configuration through custom attributes
 *
 * Implementation Guide
 * ----------------------------------------------------------------------------
 *  1. Enable rotation by adding brix-autotabs="true" to your Tabs wrapper
 *     (the element containing .w-tab-menu and .w-tab-content)
 *
 *  2. Customize individual tab timing with brix-autotabs-speed="XXXX"
 *     on any .w-tab-link element (defaults to 5000ms if not specified)
 *
 *  3. Optionally disable hover-pause by adding brix-autotabs-pauseable="false"
 *     to your Tabs wrapper (not recommended for text-heavy content)
 *
 *  Version: 1.2.0
 *  For documentation and support: https://brixtemplates.com
 */

(function() {
  'use strict';

  /**
   * parseBracketsAndLog
   * Splits a string into bracketed segments and styles them in bold.
   * Example: "Default speed: [5000ms]" => "Default speed: 5000ms" in the console, with '5000ms' in bold.
   */
  function parseBracketsAndLog(line) {
    // Split into segments: text outside brackets, plus bracketed text
    const segments = line.split(/(\[[^\]]+\])/g);
    const output = [];
    const styles = [];

    segments.forEach(segment => {
      if (!segment) return;
      if (segment.startsWith('[') && segment.endsWith(']')) {
        // Remove brackets, apply bold styling
        const text = segment.slice(1, -1);
        output.push(`%c${text}`);
        styles.push('font-weight: bold;');
      } else {
        // Normal text
        output.push(`%c${segment}`);
        styles.push('font-weight: normal;');
      }
    });

    // Merge into a single console.log call
    console.log(output.join(''), ...styles);
  }

  // -----------------------------------------------------------
  // TabRotator: Core functionality handler
  // -----------------------------------------------------------
  function TabRotator(container, options) {
    this.container = container;                 
    this.tabLinks = container.querySelectorAll('.w-tab-link');
    this.pauseable = options.pauseable;         
    this.defaultSpeed = options.containerSpeed; 
    this.currentIndex = 0;
    this.timer = null;
    this.isPaused = false;

    if (!this.tabLinks.length) {
      console.warn('[BRIX AutoTabs] Warning: No tabs found inside this container. Rotation skipped.');
      return;
    }

    this.init();
  }

  TabRotator.prototype.init = function() {
    this.findCurrentIndex();
    this.setupEventListeners();
    this.startRotation();
  };

  TabRotator.prototype.findCurrentIndex = function() {
    let foundActive = false;
    for (let i = 0; i < this.tabLinks.length; i++) {
      if (this.tabLinks[i].classList.contains('w--current')) {
        this.currentIndex = i;
        foundActive = true;
        break;
      }
    }
    // If no active tab found, force the first tab to be active
    if (!foundActive && this.tabLinks[0]) {
      this.currentIndex = 0;
      this.simulateClick(this.tabLinks[0]);
    }
  };

  TabRotator.prototype.setupEventListeners = function() {
    const self = this;
    // Hover/touch pause
    if (this.pauseable) {
      this.container.addEventListener('mouseenter', () => self.pause());
      this.container.addEventListener('mouseleave', () => self.resume());
      this.container.addEventListener('touchstart', () => self.pause(), { passive: true });
      this.container.addEventListener('touchend', () => self.resume(), { passive: true });
      this.container.addEventListener('touchcancel', () => self.resume(), { passive: true });
    }

    // Manual interactions
    this.tabLinks.forEach(link => {
      link.addEventListener('click', () => self.resetAfterManualInteraction());
      link.addEventListener('focus', () => self.resetAfterManualInteraction());
    });
  };

  TabRotator.prototype.resetAfterManualInteraction = function() {
    clearTimeout(this.timer);
    this.timer = null;
    
    setTimeout(() => {
      this.findCurrentIndex();
      this.startRotation();
    }, 150);
  };

  TabRotator.prototype.startRotation = function() {
    if (this.isPaused) return;
    clearTimeout(this.timer);

    const currentLink = this.tabLinks[this.currentIndex];
    const speedAttr = currentLink.getAttribute('brix-autotabs-speed');
    let speed = parseInt(speedAttr, 10);

    if (isNaN(speed) || speed <= 0) {
      if (speedAttr !== null) {
        console.warn(`[BRIX AutoTabs] Invalid speed '${speedAttr}' on tab index ${this.currentIndex}. Using default of ${this.defaultSpeed}ms.`);
      }
      speed = this.defaultSpeed;
    }

    this.timer = setTimeout(() => {
      const nextIndex = (this.currentIndex + 1) % this.tabLinks.length;
      const nextLink = this.tabLinks[nextIndex];
      this.simulateClick(nextLink);

      setTimeout(() => {
        this.findCurrentIndex();
        this.startRotation();
      }, 150);
    }, speed);
  };

  TabRotator.prototype.simulateClick = function(link) {
    const storedHref = link.getAttribute('href');
    if (storedHref) {
      link.removeAttribute('href');
    }

    link.dispatchEvent(new MouseEvent('click', {
      bubbles: true,
      cancelable: true
    }));

    if (storedHref) {
      link.setAttribute('href', storedHref);
    }
  };

  TabRotator.prototype.pause = function() {
    this.isPaused = true;
    clearTimeout(this.timer);
    this.timer = null;
  };

  TabRotator.prototype.resume = function() {
    if (!this.isPaused) return;
    this.isPaused = false;
    this.startRotation();
  };

  // -----------------------------------------------------------
  // Initialization on DOM load
  // -----------------------------------------------------------
  function initBrixAutoTabs() {
    const containers = document.querySelectorAll('[brix-autotabs="true"]');
    if (!containers.length) return;

    parseBracketsAndLog('------------------------------------------------');
    parseBracketsAndLog('[AutoTabs] by [BRIX Templates] initialized successfully with the following settings:');
    parseBracketsAndLog('');

    containers.forEach((container, index) => {
      // Check if pauseable
      const pauseableAttr = container.getAttribute('brix-autotabs-pauseable');
      let isPauseable = true; 
      if (pauseableAttr && pauseableAttr.toLowerCase() === 'false') {
        isPauseable = false;
      }

      // Container default speed
      const defaultSpeedAttr = container.getAttribute('brix-autotabs-default-speed');
      let containerDefaultSpeed = 5000;
      if (defaultSpeedAttr) {
        const parsed = parseInt(defaultSpeedAttr, 10);
        if (!isNaN(parsed) && parsed > 0) {
          containerDefaultSpeed = parsed;
        } else {
          console.warn(`[BRIX AutoTabs] brix-autotabs-default-speed="${defaultSpeedAttr}" is invalid. Using 5000ms fallback.`);
        }
      }

      const links = container.querySelectorAll('.w-tab-link');
      const subCount = links.length;

      // Initialize rotator
      new TabRotator(container, { 
        pauseable: isPauseable,
        containerSpeed: containerDefaultSpeed
      });

      // Collect custom speeds
      const customSpeeds = [];
      links.forEach((link, linkIndex) => {
        const spd = link.getAttribute('brix-autotabs-speed');
        if (spd && parseInt(spd, 10) > 0) {
          customSpeeds.push(`Tab [${linkIndex + 1}] set to [${spd}ms]`);
        }
      });

      parseBracketsAndLog(`Tab [${index + 1}] has [${subCount}] sections with:`);
      parseBracketsAndLog(`  • Pause on hover: ${isPauseable ? 'enabled' : 'disabled'}`);
      parseBracketsAndLog(`  • Default base rotation: [${containerDefaultSpeed}ms]`);

      if (!customSpeeds.length) {
        parseBracketsAndLog('  • Custom rotation speed: none (all tabs use default speed)');
        parseBracketsAndLog('');
      } else if (customSpeeds.length === 1) {
        parseBracketsAndLog(`  • Custom rotation speed: ${customSpeeds[0]}, all others using default speed of [${containerDefaultSpeed}ms]`);
        parseBracketsAndLog('');
      } else {
        parseBracketsAndLog(`  • Custom rotation speed: ${customSpeeds.join(', ')}\n    all others using default speed of [${containerDefaultSpeed}ms]`);
        parseBracketsAndLog('');
      }
    });

    parseBracketsAndLog('Need to make changes? Just head to Element Settings in your Webflow designer.');
    parseBracketsAndLog('For tips and detailed configuration options, visit brixtemplates.com/blog');
    parseBracketsAndLog('------------------------------------------------');
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', initBrixAutoTabs);
  } else {
    initBrixAutoTabs();
  }

})();
</script>

While adding the script to your Webflow project settings applies it sitewide, you can also choose to implement auto-rotating tabs on specific pages only. To do this, navigate to your Page Settings instead, find the Custom Code section, and add the script there, right under the Before </body> tag code box.

Setup auto tab rotation script on Webflow page

This targeted approach can be useful when you only need the functionality on certain landing pages or product pages, helping to keep other pages free of unused code.

2. How to configure Webflow tab rotation settings

2.1 Setting up basic tab rotation

Adding the brix-autotabs="true" attribute to your Tabs wrapper element enables automatic rotation with default settings:

  • 5-second rotation speed (5000ms) between tabs
  • Automatic pause when users hover over the tabs
  • Smooth transition preservation
  • Manual click override enabled

Here's how to implement it:

  1. Select your Tabs wrapper element in the Webflow Designer
  2. Open Element Settings (gear icon) on the right sidebar
  3. Add a custom attribute:
    • Name: brix-autotabs
    • Value: true
Add attribute to Webflow tab element to auto rotate it

2.2 Customizing rotation speed for individual tabs

Different content requires different timing. Text-heavy tabs typically need 5-7 seconds for comfortable reading, while simple content can rotate more quickly at 3-4 seconds. Here's how to set custom timing:

  1. Select the specific Tab Link element
  2. Open Element Settings (gear icon) on the right sidebar
  3. Add a custom attribute:
    • Name: brix-autotabs-speed
    • Value: Your desired duration in milliseconds (e.g., 7000 for 7 seconds)
Change Webflow tabs auto rotating speed

Extra tip: If you want to change the default rotation speed for all tabs, you can use brix-autotabs-default-speed="speed in milliseconds" in your default tab container, and it will adjust the default speed for all tabs.

2.3 Managing hover pause functionality

The script comes with hover-pause enabled by default, meaning that when users hover over your tabs, they'll automatically pause. This means you don't need to do anything special to have this user-friendly feature working.

However, if you specifically want to disable this automatic pause behavior, follow these steps:

  1. Select the Tabs wrapper element
  2. Add a custom attribute:
    • Name: brix-autotabs-pauseable
    • Value: false

Consider keeping pause functionality enabled for text-heavy content to improve user experience.

2.4 Optimizing Webflow tab rotation for mobile

Optimizing your auto-rotating tabs for mobile users is crucial for a seamless experience across all devices. One effective approach is creating a separate Tabs element specifically for mobile displays using Webflow's display settings.

This allows you to apply different rotation speeds and pause behaviors tailored to touch interactions. For mobile-specific tabs, consider using longer rotation intervals since touch-based navigation typically requires more time than mouse interactions. You can achieve this by adding different brix-autotabs-speed values to your mobile-specific tabs, ensuring content remains easily readable on smaller screens.

Final testing and publishing steps in Webflow

1. Test on staging first: Always start by publishing changes to your staging/development environment (webflow.io) before going live. This gives you a safe space to verify everything works as expected.

2. Check script loading: Press F12 to open your browser console and verify you see the BRIX Templates AutoTabs initialization message without any error messages.

3. Run interaction tests: Click through each tab manually and watch several natural rotation cycles. Verify hover pausing works and transitions look smooth across all tabs.

4. Cross-browser verification: Test your implementation in Safari, Firefox and Chrome-based browsers to ensure consistent behavior.

5. Publish to production: Once everything checks out on staging, publish your changes to your live site and perform one final verification of all functionality.

Conclusion

Implementing auto-rotating tabs transforms static Webflow tab components into dynamic, engaging content showcases. This enhancement can significantly improve how visitors discover and engage with your content, whether you're highlighting product features, sharing customer testimonials, or presenting service offerings.

Need help implementing auto-rotating tabs or looking to enhance your Webflow site further? Our team of Webflow experts specializes in creating engaging, interactive experiences that drive results. Get in touch to discuss how we can help optimize your Webflow website's user experience and achieve your marketing goals.

BRIX Templates Logo
About BRIX Templates

At BRIX Templates we craft beautiful, modern and easy to use Webflow templates & UI Kits.

Explore our Webflow templates
Join the conversation
Join our monthly Webflow email newsletter!

Receive one monthly email newsletter with the best articles, resources, tutorials, and free cloneables from BRIX Templates!

Webflow Newsletter
Thanks for joining our Webflow email newsletter
Oops! Something went wrong while submitting the form.
BRIX Templates - Email Newsletter with Webflow ResourcesBRIX Templates - Email NewsletterBRIX Templates - Webflow Email Newsletter
WWW vs. non-WWW in Webflow: What is best?

WWW vs. non-WWW in Webflow: What is best?

Confused about which domain format to use on your Webflow site? Learn the pros and cons of each approach and get clear recommendations.

Mar 10, 2025
Is Webflow good in 2025? An honest analysis of strengths and limitations

Is Webflow good in 2025? An honest analysis of strengths and limitations

Wondering if Webflow is still worth it in 2025? Our detailed analysis covers the platform's evolution, new features, pricing, and more.

Mar 7, 2025
Do Webflow templates update? Understanding the template system

Do Webflow templates update? Understanding the template system

Webflow templates don't update automatically like WordPress themes. Our guide explains why, how to manage template-based sites.

Mar 7, 2025