Is there a way to force the dark mode theme in Gradio?

I already tried using:

gradio.Blocks(title="My Title", theme="darkdefault")

But no luck, any other workaround?

Thank you!!

I need to know this too. On chrome my Gradio is lightmode, and on Edge it is darkmode. How can I set it to be either one? It is ruining the design of my websites where the gradio elements are imbedded.

Huggingface imbeds are all light mode and in my browser all other gradios are dark mode, so there must be some sort of function to allow this.

Hi currently I don’t think you can pass the theme as a parameter inside your Gradio python app, but you can pass a theme URL parameter e.g.

http://localhost:7860?__theme=dark

@radames thank you for the heads up! I guess we can use some js code to enable the dark mode automatically.

This is a very hacky way to do it:

window.addEventListener('load', function () {
  gradioURL = window.location.href
  if (!gradioURL.endsWith('?__theme=dark')) {
    window.location.replace(gradioURL + '?__theme=dark');
  }
});
1 Like