How to Add Color Picker in Magento 2 Admin Configuration

Sometimes while creating an extension, you may need to provide admin the complete control of the frontend UI. Changing UI includes the change of background color, font colors which arises the need of adding color picker in Magento 2 Admin Configuration.

Generally, the settings in a Magento 2 extension resides under Stores –> Configuration and here you need to add the color picker to allow change the color in frontend UI. Here, I’ll show to add color picker in Magento 2 Admin Configuration in just three steps!

Steps to Add Color Picker in Magento 2 Admin Configuration:

  1. Add color picker to textbox through system.xml file located at app\code\Vendor\Module\etc\adminhtml
  2. Create one Color.php file at below location under the hood of extension app\code\Vendor\Module\Block
  3. Add the JS file at Vendor_Module/view/adminhtml/web/js/jscolor.js, click here to copy jscolor.js

Clear the cache and navigate to stores configuration. The color picker option will be displayed. Use this color picker anywhere in Magento 2 with your own customized code when needed!

Thanks for reading. You may post your doubts in the comments which I’ll be happy to solve.

Hit 5 stars if you like my article ?

5
(based on 17 Reviews)
How to Add Color Picker in Magento 2 Admin ConfigurationAuthor Magento Badge

Sanjay Jethva

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

2 Comments

  • vishal padhariya

    Here is the Error in system.xml file Vendor/Module/Block/Color
    This is not an Correct Line.
    The Proper Way Of Written this line is Vendor\Module\Block\Color

    There is issue about the slashes ‘ / ‘ this type of slash is not accept by the system.xml file you have to use ‘ \ ‘ this slash

Leave a Reply

Your email address will not be published.