Color-picker property definition

Warning: EXPERIMENTAL.
This API is under development. Do not rely on it. It may change or be removed in future versions.

The color-picker definition property template can be used to add a custom color-picker property. When defining a color-picker property, the following fields can be used:

Field Description
type

Used for all custom property type definitions. Can be either string, integer, number, array or boolean.

This field is mandatory and should always be "integer" for a color-picker property type definition.

Note: The color-picker effect is achieved by defining the component field to "color-picker", see below.
component Used for defining how the property is visualized in the property panel. Used to override the default component that comes with the type setting.

This field is mandatory for a color-picker property and should always be "color-picker".

ref Name or Id used to reference a property.
defaultValue Used for defining the default value of your custom property.
label Used for defining the label of the item.

Example

Defining a color-picker

Defining a custom property of color-picker type can look like below.

Example:  

Note: Customization of properties always start with items:.
define( [
],
function ( ) {
	var palette = [
        "#b0afae",
        "#7b7a78",
        "#545352",
        "#4477aa",
        "#7db8da",
        "#b6d7ea",
        "#46c646",
        "#f93f17",
        "#ffcf02",
        "#276e27",
        "#ffffff",
        "#000000"
    ];
	return {
		definition : {
			type : "items",
			component : "accordion",
			items: {
				settings: {
					uses: "settings",
					items: {
						MyColorPicker: {
							label:"My color-picker",
							component: "color-picker",
							ref: "myColor",
							type: "integer",
							defaultValue: 3
						}
					}
				}
			}
		},
		paint: function ($element, layout) {
			//add your rendering code here
			$element.css("background-color", palette[layout.myColor]);
		}
	};

} );

This is what it looks like in the property panel

Did this information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?