Skip to main content Skip to complementary content

Button group property definition

Information noteSTABLE.

This API is reliable and breaking changes are unlikely.

Fields

The button group definition property template can be used to add a custom property of radio button type. When defining a button group property, the following fields can be used:

type

This field is mandatory and should always be "string" for a button group property type definition.

Information noteThe button effect is achieved by defining the component field to "buttongroup", see below.

label

Used for defining the label that is displayed in the property panel.

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 radio button property and should always be "buttongroup".

ref

Name or ID used to reference a property.

defaultValue

Used for defining the default value of your custom property.

options

Array of options to use for dropdown, radiobuttons, buttongroup or switch components. For buttongroup it can be value, label and tooltip.

Example

options: [{
	value: "v",
	label: "Vertical",
	tooltip: "Select for vertical"
}, {
	value: "h",
	label: "Horizontal",
	tooltip: "Select for horizontal"
}],

Examples

Fetching options from an external resource

Information noteThis example is using jQuery. Make sure to have jQuery included as a require-dependency.
return {
	type: "items",
	component: "accordion",
	items: {
		settings: {
			uses: "settings",
			items: {
				MyDropdownProp: {
					type: "string",
					component: "dropdown",
					label: "Data source",
					ref: "myproperties.datasource",
					options: function() {
						return $.get("datasource.php").then(function(items){
							return items.map(function(item){
								return {
									value:item.toLowerCase(),
									label:item
								};
							});
						});
					}
Information noteOptions will be fetched every time a property is changed. It is up to the developer to cache the result from the web service if you want to avoid repeating reloads.

Defining a custom button group

Defining a custom property of button group type can look like below.

Example: Add custom button group property to Appearance accordion

Information noteCustomization of properties always start with items:.
	return {
		type: "items",
		component: "accordion",
		items: {
			settings: {
				uses: "settings",
				items: {
				MyButtongroupProp: {
						type: "string",
						component: "buttongroup",
						label: "Orientation buttons",
						ref: "myproperties.orientation",
						options: [{
							value: "v",
							label: "Vertical",
							tooltip: "Select for vertical"
						}, {
							value: "h",
							label: "Horizontal",
							tooltip: "Select for horizontal"
						}],
						defaultValue: "v"
					}
				}
			}
This is what it looks like in the property panel

An interface titled "MyNewExtension" with the subtitle "Appearance". There are two hide and show buttons called "General" and "Orientation buttons". The "Orientation buttons" hide and show button is open with two buttons as options: "Vertical" and "Horizontal".

You can also define a new accordion item as a button group property.

Example: Add custom button group property as a new accordion item

	return {
		type: "items",
		component: "accordion",
		items: {
			MyAccordion: {
				type: "string",
				component: "buttongroup",
				label: "Orientation buttons",
				ref: "myproperties.orientation",
				options: [{
					value: "v",
					label: "Vertical",
					tooltip: "Select for vertical"
				}, {
					value: "h",
					label: "Horizontal",
					tooltip: "Select for vertical"
				}],
				defaultValue: "v"
			}
This is what it looks like in the property panel

An interface titled "MyNewExtension" with the subtitle "Orientation buttons". There are two buttons below the "Orientation buttons" subtitled: "Vertical" and "Horizontal".

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!