Get Text Prop Element (Beta)

element.getTextPropElement(propId)

Returns the TextPropElement or RichTextPropElement that corresponds to a textContent or richText prop on a component instance. Returns null if the prop does not exist or is not a text-based prop.

Text prop elements behave like containers — use their append() and prepend() methods to insert child elements directly into the prop’s content area.

Beta

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

Syntax

1element.getTextPropElement(propId: string): Promise<TextPropElement | RichTextPropElement | null>

Parameters

Returns

Promise<TextPropElement | RichTextPropElement | null>

A Promise that resolves to a TextPropElement (for textContent props) or RichTextPropElement (for richText props), or null if the prop does not exist or is not a text-based prop type.

Example

1const elements = await webflow.getAllElements();
2const componentInstance = elements.find(el => el.type === 'ComponentInstance');
3
4if (componentInstance?.type === 'ComponentInstance') {
5 const props = await componentInstance.getProps();
6 const textProp = props.find(p => p.type === 'textContent');
7
8 if (textProp) {
9 const propEl = await componentInstance.getTextPropElement(textProp.id);
10
11 if (propEl) {
12 const name = await propEl.getDisplayName();
13 const children = await propEl.getChildren();
14 console.log(`Prop element "${name}" has ${children.length} child(ren)`);
15 }
16 }
17}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny