Switching to a template dark theme and "import panel.template.theme"

Hi.

I’m really struggling with switching between template default and dark themes, which should be easy but hasn’t been.

For instance, the “EditableTemplate” doesn’t have the Dark/Default slider switch at the the top of the frame, so I’m looking for a way to change the theme on-the-fly. So far nothing works. (Have an example?)

Recently I found this page:
Customize Template Theme

…with an example, but attempts to import panel.template.theme fail because it says the import doesn’t exist. Help?

1 Like

Themes in Panel I think requires a refresh. How far are you in your project?

If it’s doable, highly recommend migrating to Panel Material UI where theming works better!
https://panel-material-ui.holoviz.org/reference/page/ThemeToggle.html

Example:

import panel as pn

#template = pn.template.EditableTemplate()
#template.theme = "dark"     # Does not work, error. Theme must be set at initialization

template = pn.template.EditableTemplate(theme="dark")   # This works. But how do I change it on-the-fly?

template.servable()

Can you migrate to pmui.Page?

We are two years into a large project operating on a shoestring. Migrating dozens of pages, graphs, and hundreds of widgets to another UI is not an option.

Can you report an issue on GitHub with a minimal example?