Is it possible to change the fontsize and/or color in st.write()
?
Hi @Soren,
If you want different sizes of fonts you have two options,
- Go with the standard set of typography provided by streamlit, ie. text, title, header and subheader
https://docs.streamlit.io/en/stable/api.html#display-text - Use st markdown and give sizes yourself, This will give you text size of your choice.
import streamlit as st
st.set_page_config(layout="wide")
st.markdown("""
<style>
.big-font {
font-size:300px !important;
}
</style>
""", unsafe_allow_html=True)
st.markdown('<p class="big-font">Hello World !!</p>', unsafe_allow_html=True)
It looks like this for me
Hope it helps !
Since you were also asking about font color: we now have a built-in feature to use colored text in st.write
, st.markdown
, st.header
, etc:
st.markdown("This is black and :red[this is red!]")
You can use the colors blue, green, orange, red, violet, gray/grey, and rainbow in the same way. See also the docstring of the body
parameter.