Deprecation Notice
The legacy custom element extension has been replaced by the new site widget extension, which you can implement using custom element technology.
You can also use Wix Blocks to build a site widget based on a custom element. Learn more about custom elements with Blocks.
In your app's Extensions page, the custom element extensions are categorized as follows:
The following article is relevant only for the legacy custom element extension.
A custom element lets users drag and drop a visual extension to exactly where they want them on their site. Once a user has added it to the Wix Editor, the extension will be moveable and resizable, giving users full visual control over the extension.
Custom elements need an app settings panel that lets Wix site owners customize the app and its content.
Here's how to build your custom element:
7. Under Basic Info, complete the following:
8. If you have multiple widgets or pages with widgets, then you'll need to add the descriptions and an image for each under Widget properties.
9. Click Save.
Here's what the script looks like. Take note of the wixconfig and wixsettings attributes. Once you've loaded the code it'll trigger the connectedCallback function.
Here's what you'll see when the code's working correctly.
Each extension has a unique key that you define when adding the element. Once a user makes a change, the connectedCallback
function is triggered. This returns both a wixconfig
and wixsettings
attribute.
The extension will get a wixconfig
attribute with the following properties:
instanceId
: a unique ID of your app within a specific user's website, created whenever your app is installed on a site.
ViewMode
: gets the mode the site is currently being viewed in:
Editor
: when the site is in Editor modePreview
: when viewing a site preview in the EditorSite
: when viewing the published siteDeviceType
: gets the current device type:
Mobile
: when a user accesses the site with a mobile deviceDesktop
: when a user accesses the site with a desktop deviceNote:
If a user changes their viewMode
, connectedCallback
will be triggered.
The extension will get a wixsettings
attribute with the following property:
Note:
The Custom Element will be wrapped in an iframe in the Editor and Preview for security reasons.
During installation you have the option to bypass customParams
data and use the default settings data instead.
Example: {data:{title: “something”}}
You'll be prompted to set a data endpoint URL. This is where all changes made in the settings panel of a custom element will be sent, allowing you to sync things on your end.
We'll send data to this endpoint URL when:
published
).When a user first adds the extension the settings will be loaded with the default parameters you’ve set up. Each time a user initiates a change (e.g., changes a color), data is sent to the widget under the wixsettings
attribute.
This means that the next time the user loads the settings panel, it'll show all the recent changes.
If there are changes on the app side (e.g., a user changes a configuration on the app dashboard) you can load the configuration stored on the app side by setting the data endpoint URL. This URL will be called every time the settings panel is loaded in order to load the default configuration.
The structure of the response should be exactly like the data object generated by the settings panel (which you can see when you click ‘View Example Data Object’). If something is broken on the data object, the settings panel will revert to load the settings saved on the Wix site.
Here's how to build an effective app settings panel for your custom element:
Do some prep work before you start designing (it’ll save time in the long run):
1. Select the custom element you wish to create an app settings panel for.
4. Click the Settings Panel tab.
5. Use the Settings Panel builder to choose your settings tabs and components.
6. Click Save.
These tabs reflect the basic / core settings for your app. Some of these are a fixed requirement (and therefore locked), but you'll be able to edit some things within them. The rest are optional, and you should choose these based on what fits best with your app.
Main (required): this is always the first tab. It shows:
Settings:
In many cases, the custom element settings will be controlled from the app dashboard. However, if you want to guide users in setting up the app and define general functionality, this is the tab for it.
Layout:
This is where you’ll show users the different layouts available for your app and offer adjustments to things like spacing. Make the layouts different enough from each other so that users can easily choose the best one for them.
Display:
this gives users control over which elements are shown/hidden. For example, here you might have a toggle for 'Show Title'.
Design:
This is where users will customize the color, font and styles for different elements in your app.
Let users change your app’s colors: add a color picker for each element that users can customize. We have two color pickers:
Support (required):
This displays the following and can't be edited:
Upgrade (conditional):
This leads the user through the app upgrade flow, with the exception of two scenarios (in these scenarios, the Upgrade tab won't display):
1. The user is already on the highest paid plan.
2. You only offer a free plan.
Add Ons (conditional):
This is added automatically if you have multiple, custom size custom elements. Additional pages will be added automatically to the user's site with the option to add further widgets via the settings tab.
You need to define the widget's name, description and image on the custom element's information tab.
Each component allows the user to configure and send relevant data to your widget. Each component has the following configuration:
wixsettings
object. The key should be unique per widget.In addition, each component will hold configuration dedicated to the specific component and an optional tooltip for extra info: