Property types

Updated at:
Copy as MD

This document describes the types supported for property configuration.

bool: Switch

The property value is either true or false.

Example in the configuration pane: This property type appears as a checkbox with a text label (for example, "Power switch") and a help icon on the right.

Code example:

export default {
  "properties": [{
    "identifier": "switch",
    "defaultValue": false,
    "text": "Power switch",
    "type": "bool",
    "description": "This is a power switch.",
  }],
  "services": [],
  "events": []
};

For a usage example of the bool property type, see Local development and testing.

number: Number input

The property value is a number.

Example in the configuration pane: This property type appears as a number input with a property label on the left (for example, "Temperature"), a default value (for example, 26) in the input field, step-adjustment arrows on the right, and a data source configuration icon on the far right.

Related fields:

Parameter Type Default Description
options object / Contains additional parameters.
options.min number -Infinity The minimum allowed value.
options.max number Infinity The maximum allowed value.
options.step number 1 Specifies the increment value for the step-adjustment arrows.
options.placeholder string null The text displayed in an empty input field.

Code example:

export default {
  "properties": [{
    "identifier": "temperature",
    "defaultValue": 26,
    "text": "Temperature",
    "type": "number",
    "options": {
      "min": -10,
      "max": 36,
      "step": 2,
      "placeholder": "Enter a temperature"
    }
  }],
  "services": [],
  "events": []
};

text: Text input

The property value is a string.

Example in the configuration pane: This property type appears as a text input with a property label on the left (for example, "Temperature"), placeholder text in the input field (for example, "Temperature text"), and a data source configuration icon on the right.

Related fields:

Parameter Type Default Description
options object / Contains additional parameters.
options.maxLength number undefined The maximum number of characters allowed.
options.placeholder string Enter value The text displayed in an empty input field.
options.readOnly boolean false Specifies whether the field is read-only.
  • true: The field is read-only and cannot be manually edited.
  • false: The field is not read-only.

Code example:

export default {
  "properties": [{
    "identifier": "temperature",
    "text": "Temperature",
    "type": "text",
    "defaultValue": "Temperature text",
    "options": {
      "placeholder": "Enter a temperature",
      "maxLength": 10,
      "readOnly": true,
    }
  }],
  "services": [],
  "events": []
};

color: Color picker

The property value is an object in the format { r: number, g: number, b: number, a: number }.

The following example shows the configuration column for the attribute:

My color

This property type lets you select a color. Click the color swatch icon to the left of the input box to open the color palette.

Related fields:

Parameter Type Default Description
options object / Contains additional parameters.
options.alpha boolean | number true
  • As a boolean: Determines whether to show the alpha value configuration.
    • false: Hides the alpha configuration.
    • true: Displays the alpha configuration.
  • As a number: Sets the initial alpha value. The default is 1.
Important The value must be in { r: number, g: number, b: number, a: number } format. For rendering, convert the value to a hexadecimal format.

Code example:

export default {
  "properties": [{
    "identifier": "color",
    "text": "Color",
    "type": "color",
  }],
  "services": [],
  "events": []
};

enum: Dropdown

The value of the attribute is a string. The supported types for item.type are text, image, and icon-text.

Example in the configuration pane:

  • If item.type is text: The dropdown displays each option as plain text (for example, "Microsoft YaHei", "PingFang SC", "SimSun"). A blue checkmark appears next to the selected option.
  • If item.type is image: The dropdown displays each option as an image (for example, icons for different line styles), allowing users to preview and select the desired style visually.
  • If item.type is icon-text: Each option in the dropdown list displays an icon and a text label (for example, "Square endpoint", "Round endpoint"). A blue checkmark appears next to the selected item.

Related fields:

Parameter Type Default Description
options object / Contains additional parameters.
options.items Array [] The list of options.
options.items[].label string null The display text for the option.
options.items[].type string. One of the following: image, icon-text, or text. text The display type for the option. You can mix types.

For example, the first item.type can be text, and the second can be image.

options.items[].value any undefined The actual value of the option.
options.items[].url string null The URL of the image when the option type is image or icon-text.
options.multiple boolean false Specifies whether multiple options can be selected.
options.placeholder string null The text displayed when no option is selected.

Code example:

{
    identifier: 'valueFont',
    text: 'Test',
    type: 'enum',
    options: {
       items: [
         { label: '16', value: '16' },
         { label: '14', value: '14' },
          {
            "type": "image",
            "url": "https://img.alicdn.com/tfs/TB1mAL1khD1gK0jSZFsXXbldVXa-240-16.png",
            "label": "Dashed Line",
            "value": 2
          },
         {
          "type": "icon-text",
          "url": "https://img.alicdn.com/tfs/TB1FNnCj.D1gK0jSZFGXXbd3FXa-34-28.png",
          "label": "Round Endpoint",
          "value": 1
        },
       ],
       multiple: true,
    },
    defaultValue: 16,
  },

The options field also accepts a function to dynamically adjust the option values. See the example below:

export default {
  "properties": [{
    identifier: 'value',
    type: 'text',
    text: 'Property Value'
  }, {
    identifier: 'directionOption',
    text: 'Test',
    type: 'enum',
    disableDataSources: 'all',
    options: ({ props }) => {
      let opt;
      if (props.value === 'boolean'){
        opt = {
          items: [
            { label: '1', value: true },
            { label: '0', value: false },
          ]
        }
      }
      if (props.value === 'number') {
        opt = { 
          items: [
            { label: '>', value: '>' },
            { label: '<', value: '<' },
          ]
        }
      }
      return opt;
    },
  }],
  "services": [],
  "events": []
};

Result:

Attribute valuebooleanTest10Attribute valuenumber><

image: Image

The property value is a string that represents an image URL.

The image property type provides an image URL input. Example in the configuration pane: This appears as an input field with a property label (for example, "Select Image") and placeholder text (for example, "Enter value"). You can also expand a dropdown list to select a preset image URL.

Related fields:

Parameter Type Default Description
options object / Contains additional parameters.
options.items Array [] A list of preset images available in the dropdown.

Code example:

export default {
  "properties": [{
    identifier: 'avatar',
    type: 'image',
    text: 'Select image',
    defaultValue: "https://img.alicdn.com/tfs/TB1S8vZqIj_B1NjSZFHXXaDWpXa-244-244.png",
    options: {
      items: [
      'https://img.alicdn.com/tfs/TB1FNnCj.D1gK0jSZFGXXbd3FXa-34-28.png',
      'https://img.alicdn.com/tfs/TB1mAL1khD1gK0jSZFsXXbldVXa-240-16.png',
    ]
    }
  }],
  "services": [],
  "events": []
};

index.js's render():

render(): JSX.Element {
        const { avatar } = this.props;

        return (
            <div>
                <img src={avatar} />
            </div>
        );
    }

Result:

Select image

group: Group

Combines multiple properties into a group in the right-side configuration pane.

The following shows an example of the property configuration column:

Flowing arrowArrow directionArrow color

Related fields:

Parameter Type Default Description
displayIdentifier string null The identifier for the group's checkbox value, which can be true or false.
displayDefaultValue boolean N/A
Note If this field is configured, a checkbox appears to the left of the group name. Otherwise, no checkbox is displayed.
Indicates whether the group is checked:
  • true: The checkbox is selected, and sub-properties are visible.
  • false: The checkbox is cleared, and sub-properties are hidden. Their values remain accessible in your code.

Code example:

export default {
  "properties": [{
    identifier: 'arrowGroup',
    text: 'Flowing arrow',
    type: 'group',
    displayIdentifier: 'showArrow',
    displayDefaultValue: true,
    options: {
      items: [
        {
          identifier: 'arrowDirection',
          text: 'Arrow direction',
          type: 'enum',
          options: {
            items: [
              { label: 'To the left', value: 'left' },
              { label: 'To the right', value: 'right' },
            ],
          },
          defaultValue: 'left',
        },
        {
          identifier: 'arrowColor',
          text: 'Arrow color',
          type: 'color',
          defaultValue: { r: 14, g: 155, b: 255, a: 1 },
        },
      ]
    }
  }],
  "services": [],
  "events": []
};

pureDataSource: Pure data source

A property that is configured exclusively through a data source.

The configuration column for a property is displayed as follows:

Configure a data source

Related fields:

Parameter Type Default Description
dataTypes array [] An array of data types that the data source can return. If the returned data type is not in this list, an error is reported in the visualization workbench.

Valid values include: Array, Boolean, DateTime, Enum, Integer, JSONObject, Number, OneDimensionData, TwoDimensionData, PagingTwoDimensionData, RgbaColor, and String.

needPropValue boolean false Set this to true if you need to access propValues within functions like options or linkage for a property that is bound to a data source.
options object / Contains additional parameters.
options.dataSourceInfoErrorTip string null The error message to display when the data source configuration is incorrect.
options.showDataSourceInfo boolean false Specifies whether to display the source of the data.

Code example:

export default {
  "properties": [{
    identifier: 'dataSource',
    text: 'Device name',
    type: 'pureDataSource',
    dataTypes: ['Number', 'Enum', 'Boolean'],
    options:{
      dataSourceInfoErrorTip:'The API must return a number, boolean, or enum value to configure the fan status.',
      showDataSourceInfo: true,
    },
  }],
  "services": [],
  "events": []
};