The color control allows you to create colorpickers. WordPress uses iris for colorpickers and Kirki extends the default WordPress Color controls adding the ability to select rgba colors with the addition of an opacity slider.

Example

Adding a hex-only colorpicker

Kirki::add_field('theme_config_id',['type'=>'color','settings'=>'color_setting_hex','label'=>__('Color Control (hex-only)','kirki'),'description'=>esc_html__('This is a color control - without alpha channel.','kirki'),'section'=>'section_id','default'=>'#0088CC',]);

Adding an rgba colorpicker

Kirki::add_field('theme_config_id',['type'=>'color','settings'=>'color_setting_rgba','label'=>__('Color Control (with alpha channel)','kirki'),'description'=>esc_html__('This is a color control - with alpha channel.','kirki'),'section'=>'section_id','default'=>'#0088CC','choices'=>['alpha'=>true,],]);

Adding a hue-only colorpicker

Kirki::add_field('theme_config_id',['type'=>'color','settings'=>'color_setting_hue','label'=>__('Color Control - hue only.','kirki'),'description'=>esc_html__('This is a color control - hue only.','kirki'),'section'=>'section_id','default'=>'#0088CC','mode'=>'hue',]);

Caution:

If you use a hue-only control the saved value will not be a hex or rgba color. Instead the value will be an integer. You can use that value in HSL or HSLA colors in your themes. For more info on HSLA you can read this article

Usage

Most times you won’t have to manually retrieve the value of color controls since the output argument can cover most use-cases.

<divstyle="color:<?phpechoget_theme_mod('my_setting','#FFFFFF');?>"><p>The text-color of this div is controlled by "my_setting".
</div>

Licence

Kirki is licenced under the MIT Licence. It is 100% open-souce and you can use it on your projects.

Though not legally necessary, we would appreciate if you mention in your project's page that use Kirki and link to this project.

Support

Support is provided from the github repository. Though we do our best to reply to everyone in a timely manner and address any questions or issues you might have, keep in mind that Kirki is an open-source project maintained by people donating hundreds of hours.