Check documentation for the latest version of dhtmlxSuite Manipulating Colors DHTMLX Docs

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 as:

  • a string with the 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 returned by the getSelectedColor method:

var colorSelected = myColorPicker.getSelectedColor();

Setting Custom Colors

A custom colors palette can be shown by setting the custom_colors parameter to true. This palette can be used to keep colors that are most used by a user. The colors can be added there by end-users in the following way:

  • selecting the necessary color;
  • pressing the "Add To Custom Colors" button.

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

myColorPicker.setCustomColors(colors);

The colors parameter is an array of predefined colors in the Hex color format:

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