For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceGuidesExamplesChangelog
ReferenceGuidesExamplesChangelog
  • Designer API
    • Introduction
    • Getting Started
    • Webflow CLI
    • Error Handling
    • App Modes
  • Elements
    • Creating & Retrieving Elements
    • Element Properties & Methods
      • Attributes
        • Get Attributes
        • Get Resolved Attributes
        • Set Attributes
        • Set Attribute
        • Get Attribute Value
        • Get Resolved Attribute Value
        • Remove Attribute
      • Custom Attributes
      • Styles
      • Text Content
      • Display Name
    • Element Types & Methods
  • Styles
    • Managing Style Properties
    • Managing Variable Modes
  • Components
  • Variables & Collections
    • Variable Collections
    • Variables
    • Variable Modes
  • Assets
  • Pages & Folders
  • Utilities
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • element.setAttributes(attrs)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer Ability
ElementsElement Properties & MethodsAttributes

Set attributes (Beta)

Was this page helpful?
Previous

Set attribute (Beta)

Next
Built with

element.setAttributes(attrs)

Replace all attributes on an element with the provided array of attribute names and values. Both the name and value of each entry can be a string or a BindingValue object.

This method replaces the complete set of attributes — it does not perform a partial update. Any attributes not included in the array are removed.

To set a single attribute without replacing the others, use element.setAttribute().

Beta

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

Syntax

1element.setAttributes(attrs: Array<AttributeEntry>): Promise<null>

Parameters

  • attrs : Array<AttributeEntry> — The complete list of attributes to set on the element. Any existing attributes not included in this array are removed.

Related types:

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

Returns

Promise<null>

A Promise that resolves to null.

Example

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

Try this example

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canDesignPrimaryMainCanvasDesign