
How-to: Dark Mode on Shiny for Python apps✨
image: thumbnail.jpg
Transcript#
This transcript was generated automatically and may contain errors.
You know what looks great? Your Shiny apps. And you know what looks even better? Your Shiny apps at night with Dark Mode. I'm going to show you how you can easily add Dark Mode to Shiny for Python apps with three quick steps. Here I have a simple app with a histogram that reacts to an input slider that's stored in a sidebar. So for the first step, I'm going to add UIInputDarkMode.
This adds a toggle button that makes it easy for users to switch between light and dark mode. And in many apps, this is all you need. In my app, I'd like to be able to see the text of this plot. The second step is to give your Dark Mode button an ID. This lets you react to the current theme in your server logic. I've written plotHistogram so that it takes a foreground color, which is currently set to black. But now we can react to the current color mode and choose black if the mode is light, otherwise silver. And just like that, we have an app that looks good by day or night.
And just like that, we have an app that looks good by day or night.
