Set selected element

webflow.setSelectedElement()

Set the selected element on the current page, or on the current component when the Designer is entered into a component.

The returned element object can be further queried using element-level properties (e.g. type, styles) and methods (e.g. getChildren())

Syntax

webflow.setSelectedElement(element: AnyElement): Promise<AnyElement>

Parameters

  • Element: AnyElement - Any element that is on the current canvas, or is with the current component when the designer is entered into a component.

Returns

Promise<AnyElement>

A Promise that resolves to AnyElement.

Example

// Get the Root Element
const rootElement = await webflow.getRootElement();
if (rootElement) {
// Select the root element
const selectedElement = await webflow.setSelectedElement(rootElement);
if (selectedElement?.children) {
// Start building elements on the selected element
await selectedElement?.append(webflow.elementPresets.DOM)
}
}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny