Creating & Retrieving Elements
Managing elements is a core aspect of working with the Webflow Designer API. This section covers methods for creating new elements, selecting existing ones, and managing their placement in the element hierarchy.
Element selection
Before manipulating elements on the canvas, you typically need to select them. The Designer API provides methods to get references to existing elements:
Adding elements to the Canvas
When adding elements to your design, you need to consider their placement within the element hierarchy. The Designer API provides several methods for inserting elements precisely where you need them.
Element Presets
The Designer API uses Element Presets to specify which type of element to create. Each preset corresponds to a unique element type in Webflow. Some element types include their own properties and methods.
For a complete list of available presets, refer to the Element Presets documentation. These presets can be used with any of the element creation methods shown below.
Inserting elements next to existing elements
To position an element alongside existing elements:
Parent elements
If the selected element has a parent element, the new element created using before()
or after()
will also be a child element of the same parent.
Nesting elements within parent elements
To create parent-child relationships by nesting elements:
Bulk adding elements
For more complex structures, you can create multiple elements at once using element builder:
Removing elements
To remove an element from the canvas:
Methods
The Elements API offers the following methods for element creation and manipulation:
Retrieve the currently selected element in the Designer.
Programmatically select an element in the Designer.
Retrieve all elements on the current page.
Insert a new element before the target element.
Insert a new element after the target element.
Insert a new element as the first child of the target element.
Insert a new element as the last child of the target element.
Add multiple elements at once with a hierarchical structure.
Remove an element from the canvas.