element.getComponent()

Retrieves the associated component definition of the component instance.

Syntax

1element.getComponent(): Promise<Component>

Returns

Promise<Component>

A Promise that resolves to a Component Object

Example

1// Select Component Element on Page
2const elements = await webflow.getAllElements()
3const componentInstance = elements.find(el => el.type === 'ComponentInstance')
4
5if (componentInstance?.type === "ComponentInstance") {
6
7 // Get Component object from instance
8 const component = await componentInstance?.getComponent()
9 const componentName = await component.getName()
10 console.log(componentName)
11} else {
12 console.log("No component element found")
13}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny
Built with