Skip to content

Create a Custom Panel

Similar to registering custom components, the CE.SDK web editor allows you to render custom panels. Built-in UI elements ensure that your custom panel blends seamlessly with the editor’s look and feel, while still enabling you to adapt the editor to your unique workflows.

registerPanel(panelId: string, renderFunction: ({ builder, engine, state }) => void)

Registers a panel whose content can be rendered with a panel builder, similar to how custom components are registered.

The builder’s render function is called with three arguments: the builder, the engine, and the state. The builder object is used to define which base components (such as buttons) should be rendered. The engine is used to retrieve any state from the engine. The render function will be called again if any engine-related state changes occur due to engine calls or the local state was updated.

  • panelId: The unique ID of the new registered panel.
  • renderFunction: The render function of the panel.

When is a Panel Rendered?

It is important concept to understand when a panel re-renders after its initial rendering. The component assumes that all its state is stored in the engine or the local state. Whenever we detect a change that is relevant for this panel it will re-render.

Using the Engine

Inside the render function, any calls that retrieve values from the engine will be tracked. If a change is detected, the render function will be automatically re-called.

For example, in a panel, we could query for all selected blocks and decide whether to render a button based on the result. The engine detects the call to findAllSelected and knows that if the selection changes, it needs to re-render the panel. This behavior applies to all methods provided by the engine.

Using Local State

Besides the engine, the render function also receives a state argument to manage local state. This can be used to control input components or store state in general. When the state changes, the panel will be re-rendered as well.

The state argument is a function that is called with a unique ID for the state. Any subsequent call to the state within this panel will return the same state. The second optional argument is the default value for this state. If the state has not been set yet, it will return this value. Without this argument, you’ll need to handle undefined values manually.

The return value of the state call is an object with value and setValue properties, which can be used to get and set the state. Since these property names match those used by input components, the object can be directly spread into the component options.

cesdk.ui.registerPanel('counter', ({ builder, state }) => {
const urlState = state('url', '');
const { value, setValue } = state('counter', 0);
builder.Section('counter', {
children: () => {
builder.TextInput('text-input-1', {
inputLabel: 'TextInput 1',
...urlState
});
builder.Button('submit-button', {
label: 'Submit',
onClick: () => {
const pressed = value + 1;
setValue(pressed);
console.log(
`Pressed ${pressed} times with the current URL ${urlState.value}`
);
}
});
}
});
});

Integrate the Panel into the Editor

After registering a component, it is not automatically opened or integrated in any other way. The CE.SDK editor is just aware that there is a panel with this id.

Opening a Panel

Once a panel is registered, it can be controlled using the Panel API, just like any other panel. For instance, you can open a custom panel with cesdk.ui.openPanel(registeredPanelId). Other settings, such as position and floating, can also be adjusted accordingly. The payload passed by openPanel is also accessible within the panel’s render function.

In most cases, you will want to open it using a custom button, .e.g in a button inside the Dock or Inspector Bar.

Setting the Title of a Custom Panel

The title of a panel is determined by a translation based on the panel’s ID. For example, if the panel ID is myCustomPanel, the corresponding translation key would be panel.myCustomPanel.

cesdk.setTranslations({
en: {
'panel.myCustomPanel': 'My Custom Panel',
},
de: {
'panel.myCustomPanel': 'Mein eigenes Panel',
}
});

Using the Builder

The builder object passed to the render function provides a set of methods to create UI elements. Calling this method will add a builder component to the user interface. This includes buttons, dropdowns, text, etc.

Builder Components

The following builder components can be used inside a registered panel.

Button

A simple button to react on a user click.

PropertyDescription
labelThe label inside the button. If it is a i18n key, it will be used for translation.
labelAlignmentHow the label inside the button is aligned. Either left or center.
inputLabelAn optional label next to/above the button. If it is a i18n key, it will be used for translation.
inputLabelPositionInput label position relative to the button - either 'top' or 'left'.
tooltipA tooltip displayed upon hover. If it is a i18n key, it will be used for translation.
onClickExecuted when the button is clicked.
variantThe variant of the button. regular is the default variant, plain is a variant without any background or border.
colorThe color of the button. accent is the accent color to stand out, danger is a red color.
iconThe icon of the button. See Icon API for more information about how to add new icons.
trailingIconThe trailing icon of the button. See Icon API for more information about how to add new icons.
sizeThe size of the button. Either 'normal' or 'large'.
isActiveA boolean to indicate that the button is active.
isSelectedA boolean to indicate that the button is selected.
isDisabledA boolean to indicate that the button is disabled.
isLoadingA boolean to indicate that the button is in a loading state.
loadingProgressA number between 0 and 1 to indicate the progress of a loading button.
suffixAn object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components.

ButtonGroup

Grouping of multiple buttons in a single segmented control.

PropertyDescription
inputLabelAn optional label next to/above the button group. If it is a i18n key, it will be used for translation.
inputLabelPositionInput label position relative to the button group - either 'top' or 'left'.
childrenA function executed to render grouped buttons. Only the Button, Dropdown and Select builder components are allowed to be rendered inside this function.
suffixAn object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components.

Checkbox

A labeled checkbox.

PropertyDescription
inputLabelAn optional label next to the checkbox. If it is a i18n key, it will be used for translation.
inputLabelPositionInput label position relative to the checkbox - either 'left' (default) or 'right'.
iconThe icon of the checkbox. See Icon API for more information about how to add new icons.
isDisabledA boolean to indicate that the checkbox is disabled.

ColorInput

A big color swatch that opens a color picker when clicked.

PropertyDescription
inputLabelAn optional label next to the color input. If it is a i18n key, it will be used for translation.
inputLabelPositionInput label position relative to the color input - either 'left' (default) or 'top'.
iconThe icon of the checkbox. See Icon API for more information about how to add new icons.
isDisabledA boolean to indicate that the color input is disabled.
valueThe color value that the input is showing.
setValueA callback that receives the new color value when the user picks one.
suffixAn object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components.

A button that opens a dropdown with additional content when the user clicks on it.

PropertyDescription
labelThe label inside the button. If it is a i18n key, it will be used for translation.
tooltipA tooltip displayed upon hover. If it is a i18n key, it will be used for translation.
variantThe variant of the button. regular is the default variant, plain is a variant without any background or border.
colorThe color of the button. accent is the accent color to stand out, danger is a red color.
iconThe icon of the button. See Icon API for more information about how to add new icons.
isActiveA boolean to indicate that the button is active.
isSelectedA boolean to indicate that the button is selected.
isDisabledA boolean to indicate that the button is disabled.
isLoadingA boolean to indicate that the button is in a loading state.
loadingProgressA number between 0 and 1 to indicate the progress of a loading button.
childrenA function executed to render the content of the dropdown. Every builder component called in this children function, will be rendered in the dropdown.
suffixAn object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components.

Heading

Renders its content as heading to the panel.

PropertyDescription
contentThe content of the header as a string.

Library

A complete asset library with a search option.

PropertyDescription
entriesAn array of Asset Library entry IDs that determines which assets are shown in which way. See Asset Library Entry for reference.
onSelectA callback receiving the selected asset when the user picks one.
searchableWhen set, makes the Library searchable.

MediaPreview

A large preview area showing an image or color. Optionally contains a button in the bottom right corner, offering contextual action.

PropertyDescription
sizeSize of the preview, either 'small' or 'medium' (default).
previewDetermines the kind of preview. Can be either an image, or a color. Use an object with the following shape: { type: 'image', uri: string } or { type: 'color', color: string }
actionButton option object that is passed along to the overlayed button. See Button for reference.

NumberInput

A number input field.

PropertyDescription
inputLabelAn optional label next to/above the number input. If it is a i18n key, it will be used for translation.
inputLabelPositionInput label position relative to the input - either 'top' or 'left'.
valueThe number contained in the input.
setValueA callback that receives the new number when it is changed by the user.
minMinimum value of the input.
maxMaximum value of the input.
stepInterval of changes when using the arrow keys to change the number.
suffixAn object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components.

Select

A dropdown to select one of multiple choices.

PropertyDescription
inputLabelAn optional label next to/above the control. If it is a i18n key, it will be used for translation.
inputLabelPositionInput label position relative to the control - either 'top' or 'left'.
tooltipA tooltip displayed upon hover. If it is a i18n key, it will be used for translation.
valueThe currently selected value.
setValueA callback that receives the new selection when it is changed by the user.
valuesThe set of values from which the user can select.
isDisabledA boolean to indicate that the control is disabled.
isLoadingA boolean to indicate that the control is in a loading state.
loadingProgressA number between 0 and 1 to indicate the progress of loading.
suffixAn object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components.

Separator

Adds a separator (<hr> element) in the panel to help the visual separation of entries. This builder component has no properties.

Slider

A slider for intuitively adjusting a number.

PropertyDescription
inputLabelAn optional label next to/above the text field. If it is a i18n key, it will be used for translation.
inputLabelPositionInput label position relative to the input - either 'top' or 'left'.
valueThe text contained in the field.
setValueA callback that receives the new text when it is changed by the user.
minMinimum value of the slider.
maxMaximum value of the slider.
stepInterval of the slider movement.
centeredAdds a snapping point in the middle of the slider.
suffixAn object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components.

Text

A piece of non-interactive text.

PropertyDescription
contentThe content of the text as a string.

TextArea

A large text field accepting user input.

PropertyDescription
inputLabelAn optional label above the text field. If it is a i18n key, it will be used for translation.
valueThe text contained in the field.
setValueA callback that receives the new text when it is changed by the user.
isDisabledA boolean to indicate that the text area is disabled.
placeholderHint text shown when the field is empty.
suffixAn object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the input label. Please note that the suffix is not rendered if there is no input label. If the object includes only an icon (with a tooltip), only the icon will be displayed.

TextInput

A small text field accepting user input.

PropertyDescription
inputLabelAn optional label next to/above the text field. If it is a i18n key, it will be used for translation.
inputLabelPositionInput label position relative to the input - either 'top' or 'left'.
valueThe text contained in the field.
setValueA callback that receives the new text when it is changed by the user.
isDisabledA boolean to indicate that the text field is disabled.
suffixAn object with properties similar to those of a Button. When provided, it will render a button without a label on the right side of the component. If the object includes only an icon (with a tooltip), only the icon will be displayed. An empty object will render as an empty space, which can be useful for aligning multiple components.