Magento 2: Add Custom Tab In Product Page

Magento 2: Add Custom Tab In Product Page

In this post, we will look at how to add a custom tab in product detail page in magento 2.

Creating file:

Create file catalog_product_view.xml in

app/design/frontend/{vender name}/{theme name}/Magento_Catalog/layout

In the file write following code:

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
   <block class="Magento\Catalog\Block\Product\View" name="custom.tab" as="customtab" template="product/view/custom_tab.phtml" group="detailed_info" >
      <arguments>
         <argument translate="true" name="title" xsi:type="string">Custom Tab Title</argument>
      </arguments>
   </block>
</referenceBlock>
</body>
</page>

Now you need to create file custom_tab.phtml in the path:

app/design/frontend/{vender name}/{theme name}/Magento_Catalog/templates/product/view

In the file you can write any content that you want to show in newly created tab.

Back to blog