Do you use st.text
? Why not st.write
, st.markdown
, or st.code
?
(Donāt ask why Iām asking this! Iāll let you know soon, but for now I just want to get some responses before I bias you with my thinking! )
Do you use st.text
? Why not st.write
, st.markdown
, or st.code
?
(Donāt ask why Iām asking this! Iāll let you know soon, but for now I just want to get some responses before I bias you with my thinking! )
Hi @thiago ,
I actually never use st.text
, only st.markdown
and st.caption
.
Sometimes st.write
, although I understand it is mostly a flexible ācatch-allā method.
Almost never⦠#st.writeTeam
I donāt think Iāve ever used st.text
either. I always for for write
, markdown
, and code
as fit for purpose.
I use it to display the output of terminal commands. That output doesnāt have a particular color scheme, so I just go with st.text
, instead of st.code
(which adds colors) or st.write
(which assumes itās just a regular markdown block).
st.text
st.write
st.code
So the only difference between st.text
and st.code
with the keyword language=None
is that the secondary background color used?
import streamlit as st
terminal = '''
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8502
Network URL: http://10.10.10.10:8502
'''
st.text(terminal)
st.code(terminal)
st.code(terminal, language=None)
how did I missed that
Youāre right, there seems to be no other difference other than that secondary background.
Ok, so hereās why Iām asking: thereās currently no way to write pure text in normal font in Streamlit.
To address this, weāve floated a few types of solutions:
Idea 1: Add a new text command, like st.plaintext(mytext)
. (Name TBD)
Idea 2: Change st.text(mytext)
so it uses normal font, andā¦
Idea 2a: ā¦add an argument like st.text(mytext, style="preformatted")
to switch to mono+preformatted text. (Again, details TBD)
or
Idea 2b: ā¦add a command for mono+pre text, like st.preformatted_text(mytext)
or
Idea 2c: ā¦donāt add any command for mono+pre text. Instead, just point people to st.code
.
Thoughts?
I vote 2a. While I still see st.code
as my primary go-to for mono font because I usually want that secondary background color and like the copy widget, I think itās nice to not preclude writing mono font directly onto the primary background. Adding a style
optional keyword with mono default makes it a non-breaking change.
Thats a useful comparison thanks
Never used st.text. I only use st.markdown for hiding, st.write for text, and st.latex for LaTeX.
Thanks all! Iāll share this with the team. Very helpful