The product tabs on the product item page in Magento, how would I go making all the tabs collapsed by default on mobile view?


Create a copy of the core details file in your local theme: app/design/frontend/{Vendor}/{Theme}/Magento_Catalog/templates/product/view/details.phtml and remove the data-mage-init='{"tabs":{"openedState":"active"}}' and add the following:

<script type="text/javascript">
        require(['jquery', 'matchMedia', 'accordion'], function($, mediaCheck) {

            var detailsTabs = $('.product.data.items');

                media: '(min-width: 768px)',
                // Switch to Desktop Version
                entry: function () {
                        openedState: "active",
                        collapsible: false
                // Switch to Mobile Version
                exit: function () {
                        openedState: "active",
                        collapsible: true,
                        active: false
  • Thanks @Stevie-Ray it helps me. Dec 16 '19 at 7:19
  • Thanks for the solution brother, It's worked but how to keep first tab is open on load in mobile view? Jun 24 at 15:34

extend tabs.js from magento core to set the option collapsible to true. I think that should collapse them by default.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.