Bulk Add Elements
webflow.elementBuilder(preset)
Construct complex element structures before adding them to a page. This method is optimized for bulk creation of elements, and is particularly useful when working with SVG graphics or nested element groups like a navigation menu. This approach is more efficient than creating and adding elements one at a time, especially for complex designs.
Current Limitations
Currently, only DOM elements can be created with the element builder.
Syntax
Parameters
- preset: The DOM element preset from the Webflow presets. Currently, only DOM elements are supported.
Returns
BuilderElement
A builder element object designed for creating and manipulating hierarchical structures. This object has these methods:
append()
: Add a child element to this builder elementsetTag()
: Set the HTML tag for this DOM elementsetAttribute()
: Set an attribute on this DOM elementsetTextContent()
: Set the text within this DOM elementsetStyles()
: Set styles on this DOM element
How to use the element builder
Get the parent element
Use webflow.getSelectedElement()
to select the parent element. This is where your new structure will be added.
Create a builder element
Use webflow.elementBuilder(webflow.elementPresets.DOM)
to create a builder element.
Configure the builder element
Use the builder element to configure the tags, attributes, and styles of the new structure.
Examples
Create a navigation menu
SVG with multiple paths
When to use element builder
The element builder is particularly useful for:
- Complex Element Structures: When creating hierarchies with many nested elements
- SVG Creation: Perfect for building SVG graphics with many path, circle, or other elements
- Repeating Patterns: When you need to create many similar elements
- Performance: More efficient than adding elements one-by-one to the canvas
Best practices
- Build Complete Structures: Create your entire element structure before adding it to the canvas
- Set Properties: Configure tags, attributes, styles, and text content on builder elements before appending
- Track References: If you need to modify elements after adding to canvas, store references to them
- Batch Operations: Use
Promise.all
for batch operations when modifying multiple elements