dev-resources.site
for different kinds of informations.
Hyva: Display PDP Sections as Tabs on Desktop and Accordion on Mobile
Published at
12/10/2024
Categories
hyvathemes
magneto
magentodevelopment
hyva
Author
evrig_solutions_
Author
16 person written this
evrig_solutions_
open
In this tutorial, Today We will explain How to make PDP Sections display as Tabs in Desktop View and Accordion in Mobile View instead of Cards.
**Step 1: Add the Code
**You just copy and paste the below code into your PHTML File, CMS block, or CMS Page.
<div x-data="{ tab: 'tab1' }" id="tab_wrapper">
<div class="text-center border-gray-300 border-b hidden md:flex md:justify-cente`r">
<div :class="{ 'text-red-800': tab === 'tab1' }" @click.prevent="tab = 'tab1'" class="text-xl mx-4 font-bold text-black cursor-pointer">TAB-1</div>
<div :class="{ 'text-red-800': tab === 'tab2' }" @click.prevent="tab = 'tab2'" class="text-xl mx-4 font-bold text-black cursor-pointer">TAB-2</div>
</div>
<div>
<div class="md:hidden text-xl font-bold cursor-pointer p-2 text-black bg-gray-100 border border-gray-300"
@click="tab = 'tab1'"
:class="{ 'active text-red-800': tab === 'tab1' }">
TAB-1
</div>
<div x-show="tab === 'tab1'" class="p-3">
<h2>TAB-1 Content</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,</p>
</div>
</div>
<div>
<div class="md:hidden text-xl font-bold cursor-pointer p-2 text-black bg-gray-100 border border-gray-300"
@click="tab = 'tab2'"
:class="{ 'active text-red-800': tab === 'tab2' }">
TAB-2
</div>
<div x-show="tab === 'tab2'" class="p-3">
<h2>TAB-2 Content</h2>
<p> but also the leap into electronic typesetting, remaining unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </p>
</div>
</div>
</div>
```
**Step 2: Run the Commands
**Run the below commands to see your changes
`bin/magento cache:clean`
```
npm run build-prod
```
- Thebin/magento cache:clean command clears your Magento cache.
- The npm run build-prod command builds your Tailwind styles in the theme directory:
app/design/frontend/Vendor/default/web/tailwind
**Advantages of This Approach
**
- Achieve this without adding any external JS/CSS.
- Minimal use of Tailwind classes and Alpine.
- Customizable: You can change the design to meet your requirements.
- Mobile friendly: It will convert accordion in the mobile view.
- Responsive: This code adapts its layout to different screen sizes, ensuring your code looks great on all devices.
**_[Get in Touch
](https://www.evrig.com/contact-us/)_**If youβre looking to optimize your PDP for better functionality, speed and user experience, reach out to us today! Whether itβs [Hyva](https://www.evrig.com/magento-2-hyva-theme-development-company/), custom development or performance optimization, we can help you achieve your business goals.
Contact Evrig for a free consultation and see how we can help you create seamless, engaging e-commerce solutions!
magneto Article's
29 articles in total
Boost Your eCommerce Success with the Best Magento 2 Extensions
read article
Boost Your eCommerce Success with the Best Magento 2 Extensions
read article
How to Install Magento 2 on Shared Hosting ?
read article
Magento 2 commands for maintenance and deployment
read article
Here's an easy way to create a Magento 2 eCommerce custom theme
read article
Hyva : How to create Read More Read Less Button
read article
Why Our Magento agency Stands Out in E-Commerce Excellence?
read article
Hyva release version: 1.3.10 for performance and User experience
read article
How Magento Ecommerce Can Drive Revenue and Growth for Your Business
read article
Hyva: Display PDP Sections as Tabs on Desktop and Accordion on Mobile
currently reading
Welcome to ViraXpress (Open source Magento frontend)
read article
Magento 2 ARM Ubuntu Server 24.04 AMD installation sh script
read article
How to Create a Dynamic Magento 2 Cart Page Using ReactJS
read article
Step-by-Step Guide: Setting Up Google Analytics 4 in Magento 2
read article
Creating a Custom Theme in Magento: A Step-by-Step Guide
read article
Common Misconfigurations that Make Magento Stores Vulnerable to Attacks
read article
Migration from Magento to Medusa: A Complete Guide for CTO
read article
Top Black Magic Specialist in Mumbai
read article
Magento Development Company
read article
Why Choose Magento 2 Maintenance Services: Know the Main Reasons
read article
What is Magento and Why Should You Use It for E-commerce?
read article
What is Magento 2 Payment Restrictions?
read article
10+ Best Sites to Hire Magento Developers
read article
Enhance Your Site with a Magento Website Audit Checklist 2024
read article
Technology Stack Comparison: Magento vs. Saleor
read article
Magento 2 Slack Notifier Module
read article
Best Magento Security Practices to Follow in an E-commerce Website Development Company
read article
Magento Web Development Company | Impinge Solutions
read article
What Are The Parameters of The around Method in Magento 2
read article
Featured ones: