---
title: "Magento 2: How to Add Custom Tab on Admin Dashboard"
url: "https://magecomp.com/blog/magento-2-add-custom-tab-on-admin-dashboard/"
date: "2023-10-13T15:04:44+00:00"
modified: "2025-02-13T04:44:01+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 640
reading_time: "4 min read"
summary: "Hello Magento Friends,"
description: "Learn How to Add Custom Tab on Admin dashboard in Magento 2."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Magento 2: How to Create a Category using Data Patch"
    url: "https://magecomp.com/blog/magento-2-create-category-using-data-patch/"
  - title: "The Best Custom Magento Development Services"
    url: "https://magecomp.com/blog/best-custom-magento-development-services/"
  - title: "How to Add Block After Add to Cart Button in Magento 2 Product page?"
    url: "https://magecomp.com/blog/add-block-add-cart-button-magento-2-product-page/"
---

# Magento 2: How to Add Custom Tab on Admin Dashboard

_Published: October 13, 2023_  
_Author: Dhiren Vasoya_  

![How to Add Custom Tab on Admin Dashboard M2](https://magecomp.com/blog/wp-content/uploads/2023/10/How-to-Add-Custom-Tab-on-Admin-Dashboard-M2-1024x512.webp)

**Hello Magento Friends,**

In today’s blog, we will learn How to Add Custom Tab on Admin Dashboard in Magento 2.
[![Magento Malware Removal](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-Malware-Removal-CTA-4.webp)](https://magecomp.com/magento-malware-removal.html)

Creating a custom tab on the admin dashboard in Magento 2 can be a useful way to display specific information or tools that are relevant to your business. Here’s a step-by-step guide on how to add a custom tab on the Magento 2 admin dashboard:
## Steps to Add Custom Tab on Admin Dashboard in Magento 2:
**Step 1:** First, we need to create a **“routes.xml”** file inside the extension at the following path.
**app\code\Vendor\Extension\etc\adminhtml\**

Then add the code as follows
```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="vendor" frontName="vendor">
            <module name="Vendor_Extension" before="Vendor_Extension" />
        </route>
    </router>
</config>
```

**Step 2:** After that, we need to create the **“Bestvendors.php”** file inside the extension at the following path.
**app\code\Vendor\Extension\Controller\Adminhtml\Dashboard**

And add the below-mentioned code
```
<?php
namespace VendorExtensionControllerAdminhtmlDashboard;

use MagentoBackendAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoBackendControllerAdminhtmlDashboardAjaxBlock;
use MagentoFrameworkControllerResultRawFactory;
use MagentoFrameworkViewLayoutFactory;

class Bestvendors extends AjaxBlock
{
    protected $resultRawFactory;
    protected $layoutFactory;

    public function __construct(
        Context $context,
        RawFactory $resultRawFactory,
        LayoutFactory $layoutFactory,
        PageFactory $resultPageFactory
    ) {
        parent::__construct($context,$resultRawFactory,$layoutFactory);
        $this->_resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        $resultPage = $this->_resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->prepend(__('Add Custom Tab'));

        $block = $resultPage->getLayout()
                ->createBlock('MagentoFrameworkViewElementTemplate')
                ->setTemplate('Vendor_Extension::custom_file.phtml')
                ->toHtml();

        $this->getResponse()->setBody($block);
    }
}
```

[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-4.webp)](https://magecomp.com/magento-performance-optimization.html)

**Step 3:** After that, we need to create a **“custom_file.phtml”** file inside the extension at the following path.
**app\code\Vendor\Extension\view\adminhtml\templates**

Now, add the following piece of code
```
     <?php echo __("Hello");?>
```

**Step 4:** After that, we need to create a **“di.xml”** file inside the extension at the following path.
**app\code\Vendor\Extension\etc\adminhtml\**

Now add the code as follows
```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <preference for="MagentoBackendBlockDashboardGrids" type="VendorExtensionBlockDashboardGrids"/>
</config>
```

**Step 5:** After that, we need to create a **“Grids.php”** file inside the extension at the following path.
**app\code\Vendor\Extension\Block\Dashboard\**

And include the below code snippet
```
<?php

namespace VendorExtensionBlockDashboard;

class Grids extends MagentoBackendBlockDashboardGrids
{
    protected function _prepareLayout()
    {
        parent::_prepareLayout();
        $this->addTab(
            'best_vendors',
            [
                'label'     => __('Best Vendors'),
                'url'       => $this->getUrl('vendor/dashboard/bestvendors', ['_current' => true]),
                'class'     => 'ajax',
                'active'    => false
            ]
        );
    }
}
```

**Step 6:** Once all files are created in your Magento, you need to run Magento upgrade, compile and deploy commands as follows.
```
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento setup:di:compile
php bin/magento cache:clean
php bin/magento cache:flush
```

**Output:**

“Best Vendor” tab added in the Magento 2 Admin Dashboard.
![Custom tab in Magento 2 admin dashboard](https://magecomp.com/blog/wp-content/uploads/2023/10/Custom-tab-in-Magento-2-admin-dashboard.png)

## Conclusion:
Hence, this way, you can add custom tabs in the admin dashboard of your Magento 2 store.
[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-4.webp)](https://magecomp.com/services/hyva-theme-development/)

There are other areas of your Magento 2 store where you can add a custom tab:
- [**Customer Account**](https://magecomp.com/blog/add-custom-tab-in-customer-account-in-magento-2/)
- [**Admin Sales Order View**](https://magecomp.com/blog/add-custom-tab-admin-sales-order-view-magento-2/)
- [**Admin Customer Edit Page**](https://magecomp.com/blog/create-custom-tab-admin-customer-edit-page-magento-2/)
- [**Product Page**](https://magecomp.com/blog/how-to-add-custom-tab-in-magento-2-product-page/)

If you have any doubts regarding the above steps, feel free to connect with me through the comment section. Share the tutorial with your friends if you found it useful. Stay in touch with us for more such Magento 2 tutorials.
**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/magento-2-add-custom-tab-on-admin-dashboard/](https://magecomp.com/blog/magento-2-add-custom-tab-on-admin-dashboard/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-07-24 02:07:01 UTC_  
