Bootstrap theme dynamic theme switch

Dear All,

as mentioned in this issue: 7099

is that any workaround to enable dynamic switching theme from light to dark in bootstrap theme. I try manual create switching still didn’t work

import panel as pn
from panel.template import BootstrapTemplate

# Initialize Panel with the Bootstrap template
pn.extension(sizing_mode="stretch_width")

# Create a global template instance
template = BootstrapTemplate(title="Theme Toggle Example", theme="default")

# Content for the template
markdown = pn.pane.Markdown(
    """
    ## Theme Toggle Example
    This is a demonstration of toggling between light and dark themes dynamically.
    """,
    align="center"
)

# Create a theme toggle button
theme_toggle_button = pn.widgets.Button(name="Toggle Theme", button_type="primary")

# Define a callback for theme toggling
def toggle_theme(event):
    current_theme = template.theme
    new_theme = "dark" if current_theme == "default" else "default"
    template.theme = new_theme
    print(f"Theme switched to: {new_theme}")

# Attach the callback to the button
theme_toggle_button.on_click(toggle_theme)

# Add content to the template
template.main.append(markdown)
template.sidebar.append(theme_toggle_button)

# Serve the template
template.servable()

error code:
bokeh.min.js?v=0a5da0be1c2385c8fbc778b6fe92af35da98e7b160ed40850e1b234b02df34a055ca50d37f82f056d346f1a6812c836eecbfb99371cfc264da60861011003592:237 [bokeh 3.4.3] Unhandled ERROR reply to 2B931F5FFB6F426280988910653549AE: TypeError(‘issubclass() arg 1 must be a class’)

use this code
pn.state.template.theme_tonggle=True

is not work in bootstrap theme
thanks