The Component element represents a component instance within the Webflow Designer. Use the methods below on a component instance.

Properties

PropertyDescriptionTypeExample
idUnique identifier for the element composed of two identifiers, the component and the element.object{component: "64c813...", element: "5edf8e59-71f9..."}
typeSpecifies the type of the element.string”ComponentInstance”
childrenIndicates whether the element can contain child elements.booleanfalse
customAttributesIndicates whether the element can have custom attributes.booleanfalse
stylesIndicates whether the element can contain styles.booleanfalse
textContentIndicates whether the element can contain text contentbooleanfalse

Methods

element.getComponent()

Retrieves the associated component of the element.

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