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:
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();
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:
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