Get Component

element.getComponent()

Retrieves the associated component definition of the component instance.

Syntax

element.getComponent(): Promise<Component>

Returns

Promise<Component>

A Promise that resolves to a Component Object

Example

// Select Component Element on Page
const elements = await webflow.getAllElements()
const componentInstance = elements.find(el => el.type === 'ComponentInstance')
if (componentInstance?.type === "ComponentInstance") {
// Get Component object from instance
const component = await componentInstance?.getComponent()
const componentName = await component.getName()
console.log(componentName)
} else {
console.log("No component element found")
}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny