How can I put colored text into a text_input widget?

I am developing a Streamlit app within Snowflake.

I would like to put colored text (red or green) into a text input widget as its initial value.

I know I can produce colored text in markdown with the :color[word] syntax.

But that does not work inside of the text input e.g.:

st.text_input("HELLO","This is red :red[test]");
st.write("This is red :red[test]");
st.write("This is green :green[test]");

Gets me this:

Is it possible to do this in any way?

Thank you!

This is probably not possible as value of a text_input is going to be changed to str.

ferdy,

Thank you for the info. Its disappointing to learn that streamlit cannot support this.

However I did discover that I am able to color the label of the text_input, which might suffice for my use case:

st.text_input("this is green :green[Hello]","abc123");

Screenshot 2025-02-02 102602

1 Like