Customizing Streamlit Theme from the Command Line

Summary

I recently discovered how to select custom theme colors for your Streamlit application without modifying the config.toml file and I wanted to share with the group.

When starting your Streamlit application from the command line, you can specify the following theme related flags:

>streamlit run my_app.py --theme.base="light" --theme.primaryColor="#0066CC" --theme.backgroundColor="#FFFFFF" --theme.secondaryBackgroundColor="#F0F2F6" --theme.textColor="#262730" --theme.font="sans serif"

In addition, to change the color of the gradient bar at the top of your page, you can add the following code into your python application:

st.markdown("""
<style>
	[data-testid="stDecoration"] {
		background-image: linear-gradient(90deg, rgb(0, 102, 204), rgb(102, 255, 255));
	}
</style>""",
unsafe_allow_html=True)

I hope someone finds this helpful

6 Likes

Thanks @Dallas for sharing this with the community an awesome CSS customization.

Inspired from this solution, I’ve also done a small tweak for changing the color of the top white bar:

[data-testid="stHeader"] {
		background-image: linear-gradient(90deg, rgb(0, 102, 204), rgb(102, 255, 255));
	}

Best regards,
Chanin

2 Likes

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