Colored text

Hi guys, really noob question, but the streamlit documentation I’ve been reading on colored text doesn’t seem to work.

st.write("This is :blue[test]")

Returns the exact string instead of “This is test” with test being colored blue.

However, emojis and typography work just fine. What am I doing wrong?

What version of Streamlit are you using? Colored text was just announced with the latest version that just dropped. :smiley:

With the standard st alias, you can check using:
st.write(st.__version__)

1 Like

Ah! I’m on 1.14 still. Thanks!

1 Like

Is it possible to color printed string variables? For example

st.write("temprature: " + str(temprature))

what I’ve tried so far, I can only color the written out text in the code

Yes, it is. Here is a way to do it with f-strings, which are a bit nicer than just using + to stick strings together

temperature = "-10"

st.write(f"temprature: :blue[{temperature}]")
2 Likes

Oh, ofc! Thank you!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.