Manipulating Colors

Setting/Getting Color

The user can set the initial color for the Color Picker using the setColor() method:

myColorPicker.setColor(color);

The parameter color can be set like:

  • A string with hex color format;
  • An array of decimal values of Red, Green, and Blue;
  • A string with decimal values of Red, Green, and Blue.
myColorPicker.setColor("#123456");
//or
myColorPicker.setColor([56,34,12]);
//or
myColorPicker.setColor("rgb(10,27,99)");

The color currently selected in the Color Picker can be easily got by the method getSelectedColor():

var colorSelected = myColorPicker.getSelectedColor();

Setting Custom Colors

Custom Colors palette can be shown by setting custom colors parameter to true. This palette can be used to keep colors that are most used or popular with the user. The colors can be added there by the end-users in the following way:

  • Selecting the necessary color;
  • Pressing "Add To Custom Colors" button.

Custom colors can be also set by script through the method setCustomColors():

myColorPicker.setCustomColors(colors);

The parameter colors is the array of predefined colors written in hex color format:

myColorPicker.setCustomColors("#00f0f0",[22,66,77],"rgb(255,24,238)");
Back to top