Know the theme in code

You got this error because there are no attribute named st.theme(). Could you please share the link where people are referencing such a module? I wonder if it was a discussion about features that could be helpful. Such as this Check if the app is in dark mode or light mode at runtime

Anyway, you can take a look at Creating Custom Themes for Streamlit Apps and that would help you with your theme. Basically, you create a .streamlit folder and insert your config.toml file with the theme information.