Designer Extensions
Designer Extensions offer a powerful way to expand the functionality of the Designer. You can now create tools to help Visual Designers as they’re adding designs and functionality to their sites. But, before we jump into their development, let’s walk through how Designer Extensions work.
Designer Extensions are single-page applications that are loaded via an iframe in the Webflow Designer. This iframe can host a simple script that uses the new client-side Designer APIs, or a more complex web app that connects to a backend server and other third-party services.
Designer APIs
Designer APIs allow Apps to manage elements, properties, text, and styles on the active Canvas. These APIs interact with the browser to access and manipulate elements; handle user interactions; and retrieve data from external sources. When an App modifies an Element on the Canvas — for example, updating the padding — this change will appear to have been made directly by the user during their browser session, and will be recorded in the user’s undo/redo history.
The Webflow CLI
To access the Designer APIs, you’ll need to download and install Webflow’s CLI from NPM. Using the CLI, you’ll be able to create a starter project that automatically creates the basic structure, files, and code for your Designer Extension, which include the Objects and Methods of the Designer API that will allow you to manipulate elements on the Webflow Canvas. Learn more about the Webflow CLI in the Designer API Reference.
Download the CLI
Initialize your project
When you initialize your project with the Webflow CLI, we provide some example files that include a header, main content area, and footer for a basic web app. You can get started with an example project by typing the following command, and replacing it with your Designer Extension’s name.
Review the starter code
Let’s walk through the key files needed to bring structure, style, and dynamic content to your apps. You can always learn more about an App’s configuration, structure, and necessary files in our App Structure docs.
As you explore and modify the scaffold, don’t be afraid to experiment and make changes. The best way to learn is by doing, and the scaffold is a safe environment to try things out.
Interacting with the Designer
Designer extensions elevate App functionality by directly interacting with elements on the Canvas. Let’s explore how you can use a Designer Extension and our Designer APIs to create, modify, and delete elements on an active Canvas.
Accessing the Designer APIs
Our Designer APIs interact with the canvas via user-friendly objects and methods via The Webflow Object. With these APIs you’re able to interact with existing elements, or add new elements to the canvas.
Interacting with existing elements
Interacting with elements on the canvas typically involves three steps: referencing, staging, and syncing.
- Reference an element on the Canvas
- Stage changes to an element
- Save changes to the Designer
…
Creating new elements
In addition to manipulating existing elements, you may want to give your users the ability to add new elements to the Canvas. To do this, you can call the createDOM
method and pass the HTML tag of the type of element you’d like to create.
For example, you can create a new div
element with the following code:
You can then stage changes to this new element and sync them back to the Designer, just like with existing elements.
By understanding and using these methods, you’ll be able to create powerful and interactive Designer Extensions that can enhance the Webflow experience for users.