Creating & Retrieving Elements
Creating & Retrieving Elements
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.
Before manipulating elements on the canvas, you typically need to select them. The Designer API provides methods to get references to existing elements:
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. Including:
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.
Not all element types are supported through presets. If a preset isn’t available for the element you want to create, you can use the custom DOM element method to create a custom element.
To position an element alongside existing 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.
To create parent-child relationships by nesting elements:
For more complex structures, you can create multiple elements at once using element builder:
To remove an element from the canvas:
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.