Creating a Property Editor
A guide to creating a property editor in Umbraco.
Overview
This guide explains how to set up a property editor and hook it into Umbraco's Data Types. It also covers the creation of a basic property editor and how to test the property editor.
The steps covered in part one are:
This tutorial uses TypeScript and Lit with Umbraco. It is expected that your package is already set up to use TypeScript and Lit.
To see how to set up an extension in Umbraco using TypeScript and Lit, read the article Creating your first extension.
Resources
This tutorial will not go in-depth on how TypeScript and Lit work. To learn about TypeScript and Lit, you can find their documentation below:
The End Result
At the tutorial's end, the result is a Umbraco Suggestions Data Type, registered in the backoffice, and assigned to a Document Type. This Data Type can create and suggest values.
At each step, you will find a dropdown for suggestions-property-editor-ui.element.ts and umbraco-package.json to confirm your placement for code snippets.
Setting up a plugin
Follow the Vite Package Setup by creating a new project folder called "
suggestions" inApp_Plugins.Create a manifest file to define and configure the property editor using either JSON or TypeScript.
Create a manifest file named umbraco-package.json at the root of the suggestions folder, and add the following code:
Extension authors define the property editor UI manifest, then register it dynamically during runtime using a Backoffice Entry Point extension.
Create a manifest file named manifests.ts and add the following code:
The umbraco-package.json files are cached by the server. When creating new umbraco-package.json files, it might take a few seconds before those are loaded into the server cache.
It is important to select the right propertyEditorSchemaAlias as it affects how the Property Editor data is made available when rendering the website.
In this example, we selected the Umbraco.Plain.String because we want a string value. For more options, see the default Property Editor Schema aliases article.
Creating a Web Component
Create the web component for the property editor.
Create a file in the
srcfolder with the namesuggestions-property-editor-ui.element.tsIn this new file, add the following code:
In the
vite.config.tsfile replace theentryto the newly created.tsfile:
The basic parts of the editor are now complete, namely:
The package manifest, telling Umbraco what to load
The web component for the editor
Reload the backoffice.
Registering the Data Type in Umbraco
Add the newly added property editor "Suggestions" in the Document Type and save it.

The assigned property's value can now be edited with the new property editor.
Check out the content where you will see the property editor that looks like this:

Adding styling and setting up events in the Web Components
Start by creating an input field and some buttons to style and hook up to events.
Update the render method to include some input fields and buttons in the
suggestions-property-editor-ui.element.tsfile:
The Umbraco UI library is already a part of the backoffice, which means it can be used immediately.
Add some styling. Update the import from lit to include
cssandUmbTextStyles:
Add the CSS:
It should now look something like this:

It's starting to look good! Next, set up the event logic.
Setup Event Logic
Setup Input Field
Start with the input field. When typing something in the input field, the property editor's value should change to the input field's current value.
A change event must be dispatched, which can be done in two ways:
Using
new CustomEvent('change')orUsing
new UmbChangeEvent()which is recommended as you can leverage the core class
Add the import so the event can be used:
Add the event to the property editor:
Look at the suggestions button next.
Setup Suggestions Button
When pressing the suggestion button, the text should update to the suggestion received. Similar to how the value of the property editor changes when writing in the input field.
The value should also change when pressing the suggestion button.
Update the import for Lit:
Add suggestions to the property editor:
Update the suggestion button in the render method to call a
onSuggestionmethod when pressing the button:
Clear your cache, reload the document, and see the Suggestions Data Type running.

When saving or publishing, the value of the Data Type is automatically synced to the current content object and sent to the server.
Learn more about extending this service by visiting the Property Editors page.
Going further
With all the steps completed, a Suggestion Data Type is now running in the property editor.
The next part covers adding configurations to the property editor.
Last updated
Was this helpful?