Hello. Iām developing an app using plotly, and am having a very hard time making things work with both light and dark themes. I canāt get the plotly plots to look good in dark theme. I therefore would like to disable the dark theme option, and enforce that the app only uses the light theme. How can this be done? I have tried everything that I can think of and canāt seem to do it. The dark theme option is always there. Anyone know how to restrict the theme?
Alternatively, does anyone have any suggestions on how to make a plotly plot work well with both light and dark themes? I donāt want to use any of the default plotly themes because I donāt think any of them look particularly good, and I canāt get my plot customizations to work with them.
Thereās not currently a way to disable Dark mode completely in a streamlit app. In a soon-to-come release, weāll be providing a way to make Light/Dark the preset theme on app load, but there are currently no plans to let the option be totally disable-able.
I believe you should be able to set plotly chart colors regardless of the streamlit theme by passing a layout kwarg to st.plotly_chart and setting things in the chart according to the javascript layout API reference. The python dicts get converted to JSON objects more or less how youād expect things to work. These should eventually get plumbed to the frontend and overwrite any theming defaults set by streamlit.
Ideally, though, weād want st.plotly_chart to look good in dark mode so that this isnāt necessary. Feel free to file a GitHub issue with feedback on the current styling thatās used and how it could be improved.
This can currently be done by defining a ācustom themeā in your config.toml file:
[theme]
base="light"
Streamlit will still respect the userās settings if they manually override the theme of the app to light/dark mode, and the theme option in the settings menu will appear as āCustom Themeā, but doing this effectively sets the theme preset to light, even if the userās OS settings would cause the theme to default to dark mode.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking āAccept allā, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.