How to add color picker in system configuration options in magento 2?

How to add color picker in system configuration options in magento 2?

1.) Create system.xml at vendor/module/etc/adminhtml add below code in field

Vendor\Module\Block\Color

2.)create color.php file at Vendor/Module/Block

class Color extends \Magento\Config\Block\System\Config\Form\Field

{

public function __construct( \Magento\Backend\Block\Template\Context $context,

array $data = []

) {

parent::__construct($context, $data);

}

protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) {

$html = $element->getElementHtml();

$value = $element->getData('value');

$html .= '';

return $html;

}

}



Copyright © 2024 Tridhya Tech Limited, Inc. All rights reserved.