Search.../

text

Sets or gets the plain-text content of a TextMask element.

Description

Setting the text property sets the plain-text content of the TextMask.

Getting the text property returns the plain-text content of the TextMask.

The text property's value can contain multiple lines of text. Note that the text doesn't automatically wrap, as the TextMask element renders text as an SVG, rather than as an HTML element. As a result, to set multiple lines of text, you need to add new lines manually using template literals or newline character syntax \n. For an example of both options, see the code examples.

Min: 1 character

Max: 450 characters

Type:

stringRead & Write, default value is Current text value set in the UI.

Was this helpful?

Get the TextMask's text

Copy Code
1const myTextValue = $w('#textMask1').text // 'Text Value'
Set the TextMask's text

Copy Code
1$w('#textMask1').text = 'Text Value';
Set the TextMask's text

This example uses template literals to set multiple lines of text.

Copy Code
1$w('#textMask1').text = `Text Value Line 1
2Line 2
3Line 3`;
4
Set TextMask's text

This example uses newline character syntax to set multiple lines of text.

Copy Code
1$w('#textMask1').text = 'Text Value Line 1 \nLine 2 \nLine 3';
2