Building a Webflow CMS Dynamic Tabs Component: Step-by-Step Tutorial

Published on
August 14, 2020

Building a Webflow CMS Dynamic Tabs Component

Are you ready to learn how to build a Webflow CMS dynamic tabs component from scratch? In this tutorial, we will walk through step by step on how to create a tabs component using Webflow and the Finsweet CMS library. Whether you are a beginner or at an intermediate level, this tutorial is perfect for those who want to gain a deep understanding of how to create a dynamic tabs component in Webflow. Let's jump in and see how it works!

Setting Up the CMS

First, let's set up a tiny CMS collection in Webflow. We'll create a collection called "My Sweet Collection" and add fields for description, tab name, and image. You can add as many items as you want to this collection to have sample data to work with.

Creating the Structure in Webflow

Now, let's start by creating the structure for our dynamic tabs component in Webflow. We will start by adding a parent structure to contain our tabs component and give it some padding and spacing. Then, we'll add a content structure inside the parent element to hold our dynamic content.

Next, we'll use the native Webflow tabs component for our dynamic tabs. Within the tabs component, we'll apply unique classes such as "fs-tabs" for the entire component, "fs-tabs-menu" for the tab menu, "fs-tabs-content" for the tab content, and "fs-tabs-link" for the tab links.

Setting Up Dynamic Content

Inside the tab content, we will add a collection list wrapper connected to "My Sweet Collection" with a limited item of one. This is where we will visually manage the styles for the dynamic tabs. While we'll visually set up the structure for each tab pane, it's essential to note that in the actual HTML, we'll be removing the separate collection list wrappers for each pane. The first child inside the collection item will be copied and pasted into the tabs pane to generate the dynamic content on the published site.

Styling the Dynamic Content

We'll then style the collection list to visually represent how we want our tabs to look like. This will involve adding text, images, and links that will be dynamically populated using the CMS data.

Adding Tab Name

To ensure that the tab names are dynamically generated, we'll add a tab name using a div and text element that gets the text from our tab name field in the CMS. We will also apply the "fs-tab-name" class to it and hide it using the "fs-hide" class since we only need it to generate our tabs and don't want it to be visible in the content.

Utilizing Classes in the Visual Scriptwriter

Next, we'll use three important classes in the visual scriptwriter to generate the required JavaScript. These classes include "fs-dynamic-feed" for the feed that generates the correct amount of tabs, "fs-tab-name" for the dynamically generated tab names, and "fs-tabs" for the entire tabs component.

Applying the JavaScript

With the JavaScript generated, we'll add the provided code to the page settings in Webflow to enable the dynamic functionality of the tabs component.

Testing and Tweaking

After publishing the site, we'll see the tabs component working flawlessly with the dynamic content generated from the CMS. Additionally, we'll have the flexibility to adjust settings and apply Webflow interactions to the tab panes as needed.

Conclusion

Congratulations! You have successfully created a CMS-powered tabs component in Webflow using the Finsweet CMS library. This tutorial provides a comprehensive guide for beginners and intermediate level users looking to understand the process of building a dynamic tabs component in Webflow. If you encounter any issues or have questions, feel free to reach out to the Finsweet team for assistance. Happy building!