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 (eg. type, styles) and methods (eg. getChildren())

Syntax

1webflow.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.

1// Get the Root Element
2const rootElement = await webflow.getRootElement();
3
4if (rootElement) {
5
6 // Select the root element
7 const selectedElement = await webflow.setSelectedElement(rootElement);
8
9 if (selectedElement?.children) {
10
11 // Start building elements on the selected element
12 await selectedElement?.append(webflow.elementPresets.DOM)
13
14 }
15}

App Mode

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny