The Heading element represents an element within the Webflow Designer. The following methods are specific to Heading elements.

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''Heading’
childrenIndicates if the element can contain child elements.booleantrue
customAttributesIndicates if the element can contain custom attributes.booleantrue
stylesIndicates if the element can contain styles.booleantrue
textContentIndicates if the element can contain text contentbooleantrue

Methods

element.getHeadingLevel()

Retrieves the heading level of a heading element.

Syntax

1element.getHeadingLevel(): Promise<null | 1 | 2 | 3 | 4 | 5 | 6>

Returns

Promis<level>: Number - 1 | 2 | 3 | 4 | 5 | 6

A Promise that resolves to the value of the heading level.

Example

1const selectedElement = await webflow.getSelectedElement()
2
3if (selectedElement?.type === 'Heading'){
4
5 const headingLevel = await selectedElement.getHeadingLevel()
6 console.log(headingLevel)
7
8} else {
9 console.log("Selected Element is not a Heading Element")
10}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny

element.setHeadingLevel(level)

Set the heading level of a heading element.

Syntax

1element.setHeadingLevel(level: 1 | 2 | 3 | 4 | 5 | 6): Promise<null>

Parameters

  • level: Number - 1 | 2 | 3 | 4 | 5 | 6

Returns

Promise<null>

A Promise that resolves to null

1const selectedElement = await webflow.getSelectedElement()
2
3if (selectedElement?.type === 'Heading'){
4
5 const headingLevel = await selectedElement.setHeadingLevel(1)
6 console.log(headingLevel)
7
8} else {
9 console.log("Selected Element is not a Heading Element")
10}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canEditAnyAnyCanvasAny