When using Webflow Tabs with content populated by a single CMS item Collection List, the challenge is that all tabs may appear, but only one contains content, and Webflow doesn't automatically activate that one. You can make the tab with CMS content load as the active tab by following the steps below.
tab-pane-featured
, tab-pane-news
, etc.is-populated
, only when the CMS item is rendered.Paste the following in the Before
tag section in your project's Page Settings:
<script> window.addEventListener('DOMContentLoaded', function () { const tabLinks = document.querySelectorAll('.w-tab-link'); const tabPanes = document.querySelectorAll('.w-tab-pane'); for (let i = 0; i < tabPanes.length; i++) { const pane = tabPanes[i]; if (pane.querySelector('.is-populated')) { // Remove active classes from all tabs tabLinks.forEach(link => link.classList.remove('w--current')); tabPanes.forEach(pane => pane.classList.remove('w--tab-active')); // Add active class to the detected tab tabLinks[i].classList.add('w--current'); pane.classList.add('w--tab-active'); break; } } });</script>
🟡 Important: Adjust the .is-populated
class to match your hidden indicator or element inside the CMS-bound tab.
w--current
class from all Tab Links and w--tab-active
from all Tab Panes inside the code.To set the active tab dynamically when using a single CMS item in Webflow Tabs:
This approach ensures only the populated tab loads actively, giving a better user experience.