Get attributes (Beta)

element.getAttributes()

Get all attributes on an element as an array of name/value pairs. Both the name and value of each attribute can be a string or a BindingValue when the attribute is bound to a variable or component prop.

To get the final resolved string values with all bindings evaluated, use the method element.getResolvedAttributes().

This method is equivalent to the element.getAllCustomAttributes() method.

Beta

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

Syntax

1element.getAttributes(): Promise<Array<AttributeEntry>>

Returns

Promise<Array<AttributeEntry>>

A Promise that resolves to an array of attribute objects.

Related types:

1type AttributeEntry = {
2 name: string | BindingValue
3 value: string | BindingValue
4}

Example

1const element = await webflow.getSelectedElement()
2
3if (element && element.attributes) {
4 const attributes = await element.getAttributes()
5 console.log(attributes)
6 // [{ name: 'data-label', value: 'primary' }]
7}

Designer Ability

Checks for authorization only.

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny