Get the parent component

element.getParentComponent()

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

Beta

This feature is released as part of a Beta program and may change in 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}

Designer Ability

Checks for authorization only

Designer AbilityPermissionLocaleBranchWorkflowSitemode
canAccessCanvasanyanyanyanyany