Getting current set theme colors?


I’m working on a custom notification componenet, and I would like to know how can I get the currently set colors of the theme? (to get them via the code I mean)


+1! This would be really helpful.



Already created that :slight_smile:
an initial version.

This sounds really cool.

When you say you already created that feature, can you provide a code snippet or any other helpful insights? I have the same question, for getting the current Theme so I can set matplotlib colors based on what the theme is. Thanks!

1 Like

You can use the colors by using this:

        pc = st.get_option('theme.primaryColor')
        bc = st.get_option('theme.backgroundColor')
        sbc = st.get_option('theme.secondaryBackgroundColor')
        tc = st.get_option('theme.textColor')

If i understand right, this takes the colors ONLY if you use the external settings.
by external settings i mean creating a file names .streamlit near the app script, and input something like:
config.toml (The name of the file yo should create)

primaryColor = "#8270b3"
backgroundColor = "#0E1117"
secondaryBackgroundColor = "#2c2c2c"
textColor = "#FAFAFA"
font = "monospace"

Also you are free to edit my custom theme, it has some cool options IMHO.


1 Like