Hello Magento Friends,
Today I am going to figure out How to Use Tab Widget in Magento 2.
Tabs are used to break content into various sections to save space. The user can switch between various tabs. Magento 2 provides many readymade widgets, using that widget you can create a standard theme very easily.
Let’s learn How to Use Tab Widget in Magento 2
Step 1: To do this, override list.phtml in
app\design\frontend\Themes\Yourtheme\Magento_Catalog\templates\product\list.phtml
<div class="product info detailed"> <div class="product data items" data-mage-init='{"tabs":{"openedState":"active"}}'> <div class="data item title" data-role="collapsible" id="tab-label-1"> <a class="data switch" tabindex="-1" data-toggle="trigger" href="#temp-1" id="tab-label-1-title"> <?php __("Tab 1"); ?> </a> </div> <div class="data item content" aria-labelledby="tab-label-1-title" id="temp-1" data-role="content"> <?php __("Hello Tab 1 Text"); ?> </div> <div class="data item title" data-role="collapsible" id="tab-label-2"> <a class="data switch" tabindex="-1" data-toggle="trigger" href="#temp-2" id="tab-label-2-title"> <?php __("Hello Tab 2 Text"); ?> </a> </div> <div class="data item content" aria-labelledby="tab-label-2-title" id="temp-2" data-role="content"> Hello 2 Text </div> </div> </div>
Here I have created one theme and override list.phtml file in Magento_catalog extension. You can use the above code anywhere you want in the phtml file.
Here is the example where the two tabs appear. It will show only one segment of content at a time. Changing a new “tab” will cause others in the same group to disappear and the new one to display alone. I have selected tab 2 so it will display only tab-2 text
This way you can Use Tab Widget in Magento 2. In case of any difficulty, mention it in the comment below and share the article with your friends.
Happy Coding!
E-commerce has transformed the way consumers shop for products and services and interact with businesses.…
The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…
Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…
Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…
We're thrilled to announce the release of Hyvä Themes 1.3.6 and 1.3.7! These latest updates…
Your e-commerce platform is surging - orders are rolling in, traffic spikes are becoming the…