I need to add CSS
file for Admin side in my custom module. How can I add this for Admin (back-end) only ?
Magento 2 Adminhtml – How to Add Custom CSS
adminhtmlcssmagento2
adminhtmlcssmagento2
I need to add CSS
file for Admin side in my custom module. How can I add this for Admin (back-end) only ?
Best Answer
1 Create a module for example
Vendor/Module
, this _means a fully working module, includingregistration.php
file etc.2 Create a new file
view/adminhtml/layout/default.xml
in the module:view/adminhtml/web/css/test.css
Run below commands and check.
Optional - check css load order:
Note: css file load order might mean that your styles do not take effect, as
styles.css
gets loaded after these files.This only works
~Magento 2.3 (tested on Magento 2.3.5)
.For example: adding order to 999, ensuring that it _should be one of the last
media=all
items: