Fix light/dark theme persistence across page reloads

This commit is contained in:
oobabooga 2025-06-08 15:04:05 -07:00
parent 78899244d5
commit eb0ab9db1d
2 changed files with 21 additions and 6 deletions

View file

@ -31,7 +31,7 @@ def create_ui():
shared.gradio['toggle_dark_mode'].click(
lambda x: 'dark' if x == 'light' else 'light', gradio('theme_state'), gradio('theme_state')).then(
None, None, None, js=f'() => {{{ui.dark_theme_js}; toggleDarkMode()}}')
None, None, None, js=f'() => {{{ui.dark_theme_js}; toggleDarkMode(); localStorage.setItem("theme", document.body.classList.contains("dark") ? "dark" : "light")}}')
# Reset interface event
shared.gradio['reset_interface'].click(