For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceGuidesExamplesChangelog
ReferenceGuidesExamplesChangelog
  • Designer API
    • Introduction
    • Getting Started
    • Webflow CLI
    • Error Handling
    • App Modes
  • Elements
    • Creating & Retrieving Elements
      • Get selected element
      • Set selected element
      • Get element children
      • Get the parent component
      • Get all elements
      • Insert element before target element
      • Insert element after target element
      • Nest element as first child
      • Nest element as last child
      • Bulk Add Elements
      • Remove element
    • Element Properties & Methods
    • Element Types & Methods
  • Styles
    • Managing Style Properties
    • Managing Variable Modes
  • Components
  • Variables & Collections
    • Variable Collections
    • Variables
    • Variable Modes
  • Assets
  • Pages & Folders
  • Utilities
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • webflow.setSelectedElement()
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer Ability
ElementsCreating & Retrieving Elements

Set selected element

Was this page helpful?
Previous

Get element children

Next
Built with

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

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.

Example

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}

Try this example

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny