Add color picker to field or to any other element.

  • can be used as a component
  • alpha picker
  • multiple formats: hex, rgb, rgba, hsl, hsla


Change log

Fixed bug where no value was passed to the methods.
Fixed issues on IE7-8 when using alpha
Fixed issue when clicking on the preview
Updated the docs with information about the color object


Attached to a field with hex format specified via options.

Attachet to a field with the rgba format specified via data tag.

As component.

Using events to work with the color.

Using bootstrap-colorpicker.js

Call the colopicker via javascript:



Name type default description
format string 'hex' the color format - hex | rgb | rgba.


Format a component.

<div class="input-append color" data-color="rgb(255, 146, 180)" data-color-format="rgb">
  <input type="text" class="span2" value="" >
  <span class="add-on"><i style="background-color: rgb(255, 146, 180)"></i></span>



Initializes an colorpicker.


Show the color picker


Hide the color picker


Updates the color picker's position relative to the element

.colorpicker('setValue', value)

Set a new value for the color picker. Triggers 'changeColor' event.

Color object methods

Each triggered events have a color object used internally by the picker. This object has several usefull methods.


Set a new color. The value is parsed and tries to do a quess on the format.


Set the HUE with a value between 0 and 1.


Set the saturation with a value between 0 and 1.


Set the lightness with a value between 0 and 1.


Set the transparency with a value between 0 and 1.


Returns a hash with red, green, blue and alpha.


Returns a string with HEX format for the current color.


Returns a hash with HSLA values.


Colopicker class exposes a few events for manipulating the colors.

Event Description
show This event fires immediately when the color picker is displayed.
hide This event is fired immediately when the color picker is hidden.
changeColor This event is fired when the color is changed.
$('.colorpicker').colorpicker().on('changeColor', function(ev){
  bodyStyle.backgroundColor = ev.color.toHex();
eyecon.ro is using cookies to personalise content and ads, to provide social media features and to analyse our traffic. I also share information about your use of my site with my social media, advertising and analytics partners.See details

By continuing to browse the site you are agreeing to my use of cookies. ? Continue