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
  • element.getParentComponent()
  • Syntax
  • Returns
  • Example
  • Designer Ability
ElementsCreating & Retrieving Elements

Get the parent component

Was this page helpful?
Previous

Get all elements

Next
Built with

element.getParentComponent()

Retrieves the component that directly contains the element. Returns null if the element is not inside a component.

Beta

These methods are in public beta and may change with future releases.

Syntax

1element.getParentComponent(): Promise<Component | null>

Returns

Promise<Component | null>

A Promise that resolves to a Component, or null if the element is not inside a component.

Example

1const element = await webflow.getSelectedElement();
2if (element) {
3 const parentComponent = await element.getParentComponent();
4 if (parentComponent) {
5 const name = await parentComponent.getName();
6 console.log(`Element is inside component: ${name}`);
7 } else {
8 console.log('Element is not inside a component.');
9 }
10}

Try this example


Designer Ability

Checks for authorization only

Designer AbilityPermissionLocaleBranchWorkflowSitemode
canAccessCanvasanyanyanyanyany