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:
Was this helpful?
1const myTextValue = $w('#textMask1').text // 'Text Value'
1$w('#textMask1').text = 'Text Value';
This example uses template literals to set multiple lines of text.
1$w('#textMask1').text = `Text Value Line 12Line 23Line 3`;4
This example uses newline character syntax to set multiple lines of text.
1$w('#textMask1').text = 'Text Value Line 1 \nLine 2 \nLine 3';2