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

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

Syntax

element.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

const element = await webflow.getSelectedElement();
if (element) {
const parentComponent = await element.getParentComponent();
if (parentComponent) {
const name = await parentComponent.getName();
console.log(`Element is inside component: ${name}`);
} else {
console.log('Element is not inside a component.');
}
}

Designer Ability

Checks for authorization only

Designer AbilityPermissionLocaleBranchWorkflowSitemode
canAccessCanvasanyanyanyanyany