APIsChangelog
Log In

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

// 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)

  }
}