How to create an Admin theme in Magento 2.4

A custom theme allows the admin to have a customized backend panel with custom logo, font, responsive design which makes it easier for the admin to administer!

1.) Create theme directory

In the app/design/adminhtml directory create a new Vendor/theme directory.

app/design/adminhtml/M2e/dev/

Inside theme directory create theme.xml file


<?xml version="1.0" ?>
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>M2e admin </title> <!-- your theme's name -->
<parent>Magento/backend</parent> <!-- the parent theme-->
</theme>

2.) Create registration.php inside theme directory


<?php

use \Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::THEME, 'adminhtml/M2e/dev', __DIR__);

Now we have to Apply admin theme

3.) Create custom module to apply your admin theme

i)M2e/Dev/registration.php


<?php

use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'M2e_Dev', __DIR__);

ii)M2e/Dev/etc/module.xml


<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="M2e_Dev"/>
<sequence>
<module name="Magento_Theme"/>
</sequence>
</config>

iii) M2e/Dev/etc/di.xml


<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Theme\Model\View\Design">
<arguments>
<argument name="themes" xsi:type="array">
<item name="adminhtml" xsi:type="string">M2e/dev</item>
</argument>
</arguments>
</type>
</config>

final step install the module

php bin/magento setup:upgrade

php bin/magento setup:di:compile

One can create a custom admin theme in Magento 2 and include features like search tool, neat and clean panel arrangement, translation ready, custom colors, and much more!

Any doubts about the custom admin theme?

If so, feel free to mention them in the Comments section below.

I’d be happy to help.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *