Add a new custom element extension to your CLI project with the generate command, select Custom Element as the framework.
The CLI generates a folder with the name you choose, containing the following files:
element.extension.ts file that defines a builder containing the configuration settings for your custom element.element.tsx file that contains the main code for the custom element.element.panel.tsx file that contains the code for your widget's settings panel.element.module.css file that configures CSS styling to customize your widget's appearance. It's generated with some initial styles to help you get started.public/ folder, named <element-name>-thumbnail.png. It's the thumbnail displayed in the Add Elements panel and the Manage Apps page for your widget. This file is optional, but without a thumbnail, your widget won't appear in the Add Elements panel or the Manage Apps page.
It's possible to create each of these files yourself, but we don't recommend it for a couple of reasons:
The element.extension.ts file configures the settings for how your custom element appears on a user's site. This file is required, so don't delete it after the extension is generated. If you add your own files, you must include element.extension.ts.
When you generate a new custom element in your project, you'll see the following code in element.extension.ts:
You can edit the configuration object and add properties as follows:
| Key | Type | Description |
|---|---|---|
id | string | A unique identifier for your custom element. The CLI generates this GUID for you. If you add the JSON file yourself, you must generate your own GUID. |
name | string | The name of the custom element as it appears in the app dashboard. The CLI prompts you for the name when you create the extension. |
height.defaultHeight | number | The widget's height in pixels when it is first installed on a site. |
width.defaultWidth | number | The widget's width in pixels when it is first installed on a site. |
width.stretchByDefault | boolean | Whether to stretch the widget to full width on installation. |
width.allowStretch | boolean | Whether to allow users to toggle the widget between full-width and default width. |
installation.autoAdd | boolean | Whether the widget is automatically added to the site home page when your app is installed. If false, the widget isn't added upon install. |
presets[0].id | string | A unique GUID identifier for the preset object containing your thumbnail. |
presets[0].name | string | The display name for the preset. The CLI sets it to default. You can change it to any descriptive name. |
presets[0].thumbnailUrl | string | The URL path to your thumbnail image. Use the format {{BASE_URL}}/your-image-name.png, where your-image-name.png is the filename of your image in the public folder. Don't include public in the path. The CLI sets it to {{BASE_URL}}/<element-name>-thumbnail.png. |
Set installation.autoAdd to true to automatically add the widget to the site home page when the app is installed. Wix users can move the widget to any location after installation. If it's false, the widget isn't added on installation and Wix users can add the widget manually from the editor's Add panel. In the CLI, automatic installation applies only to the home page. For details, configuration examples, and best practices, see About custom element installation with the CLI.
The element.tsx file is where you write the code for the custom element. You can write code in other files and include it here, but you must export your custom element from this file. This is where the CLI looks for the custom element definition.
This file is required for the custom element to work, so don't delete it. If you add the files on your own, you must include element.tsx.
When the element.tsx file is generated, it looks like this:
The file defines a class called MyElement that extends HTMLElement. The class renders the display-name attribute that the generated settings panel sets. It lists display-name in observedAttributes, so the browser calls attributeChangedCallback() and the element re-renders whenever that attribute changes. The file exports the class so Wix can work with it.
The generated element code doesn't use element.module.css. It sets inline styles instead. The React example in this section imports the CSS module.
You don't need to call define(). Wix defines the custom element for you.
To write the element in React instead, wrap your React component with reactToWebComponent() and export the result. For example:
The element.panel.tsx file contains the code defining your custom element's settings panel. The settings panel lets site users customize the widget after they install your app.
In the panel's code, use Wix's JavaScript SDK to access widget properties and retrieve environmental data from the editor, as well as access and manage Wix business solutions.
To apply changes made in the settings panel to the widget, call the setProp() method in the Widget API. Widget properties are bound to your custom element's attributes, so any change in the properties automatically updates the corresponding attribute. How your custom element responds to an updated attribute depends on how you wrote element.tsx:
HTMLElement, like the generated code: List each attribute your custom element responds to in observedAttributes, and handle updates in attributeChangedCallback(). The browser calls attributeChangedCallback() only for attributes listed in observedAttributes. The generated code in the element.tsx section uses both observedAttributes and attributeChangedCallback().reactToWebComponent(): You don't need to write attributeChangedCallback(), because reactToWebComponent() handles attribute updates for you. For each prop in the props option, reactToWebComponent() reads the matching kebab-case attribute and passes the attribute's value to your React component as that prop, converted to the type you declare. For example, widget.setProp('display-name', newDisplayName) updates the display-name attribute, and the component re-renders with the new value in its displayName prop. To add a widget property, add a prop to your component and to the props option with its type. Then call widget.setProp() with the property's kebab-case name.When writing multiple properties from the panel, serialize writes and confirm each value with getProp() before the next write. See Create a Settings Panel for a Site Widget or Plugin for an example.
After the custom element is generated, you'll see code like this in element.panel.tsx file:
The file contains a React component called Panel that defines the custom element's settings panel with the following key features:
useState, useEffect, useCallback) to manage the display name property.widget API from @wix/editor to get and set widget properties.SidePanel, Input, and FormField for a consistent user interface.As with element.tsx, you can write code in other files and include it here, but you must return your main component in this file. The panel code must be written in React to work with the rest of the CLI.
Learn more about creating a settings panel for a custom element. You can also integrate Wix's native color and font pickers in your panel.
The CLI adds a thumbnail image to your project at public/<element-name>-thumbnail.png. The preset in element.extension.ts references it as {{BASE_URL}}/<element-name>-thumbnail.png in thumbnailUrl. This thumbnail displays in the Add Elements panel.
To use your own image, replace the generated file with an image of the same name. Or add a new image to the public folder and update thumbnailUrl to match.
Important:
If you rename the thumbnail file, you must update the path in thumbnailUrl. Without a thumbnail, your widget won't appear in the Add Elements panel or the Manage Apps page.
Last updated: 11 November 2026