Text element color


Just a simple question, is it possible to give a text element 2 separate colors?

So for example I have a text element with the text: “Hello World”

I can set the text.element.color and it will make the entire text the same color. Is it possible to set Hello as 1 color and World as another color without making 2 separate text elements?


Hi @nasjarta!

This is actually possible using the ‘Enable Markup’ function in the editor. Right now, color is the only thing that can be affected. Just format your text something like this:

[color="#ff0000"]red[/color] [color="#000000"]black[/color]

in the text field and make sure that ‘Enable Markup’ is selected.

I hope this is helpful!


Hi @eproasim

Thanks for your help!

Is it possible to achieve the same inside scripts as well?

Hi @nasjarta !

Yep! You just need to make sure that element.enableMarkup is set to true and then you can set element.text to your string that includes the markup information as demonstrated above.


I am still having trouble implementing this :frowning:

Markup is true

Inside my text field I got [color="#ff0000"]Hello[/color] [color="#000000"]World[/color]

And then how do I set element.text without overwriting what is inside the text field? and keeping the individual colors of Hello and World. Maybe I am understanding what you mean wrong but when I set element.text it overwrites the text and just changes to one color.

When you’re setting the field via script, are you including the old text and all of the formatting?

So if your field is initially:

element.text = '[color="#ff0000"]Hello[/color] [color="#000000"]World[/color]';

Does the new entry look like:

element.text = '[color="#ff0000"]Hello[/color] [color="#000000"]World[/color]' + randomNewText;


You will always have to rewrite/set the formatting on text when you’re replacing it in the text element. I hope that makes sense.


Yes it does, thank you so much!