Mike0021 commited on
Commit
ca16421
·
verified ·
1 Parent(s): 859f423

enforce dark theme in gradio shadow host

Browse files
Files changed (2) hide show
  1. app.py +4 -0
  2. assets/app.css +16 -1
app.py CHANGED
@@ -793,6 +793,10 @@ if __name__ == "__main__":
793
  css=APP_CSS,
794
  js="""() => {
795
  document.documentElement.classList.add('dark');
 
 
 
 
796
  try { localStorage.setItem('theme', 'dark'); } catch (_) {}
797
  }""",
798
  show_error=True,
 
793
  css=APP_CSS,
794
  js="""() => {
795
  document.documentElement.classList.add('dark');
796
+ document.body.classList.add('dark');
797
+ document.body.style.background = '#090b0f';
798
+ const host = document.querySelector('gradio-app');
799
+ if (host) host.style.background = '#090b0f';
800
  try { localStorage.setItem('theme', 'dark'); } catch (_) {}
801
  }""",
802
  show_error=True,
assets/app.css CHANGED
@@ -25,6 +25,18 @@
25
  --ms-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
26
  }
27
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  html,
29
  body {
30
  min-height: 100%;
@@ -67,7 +79,10 @@ body::after {
67
  .gradio-container,
68
  .gradio-container.dark {
69
  min-height: 100vh !important;
70
- background: transparent !important;
 
 
 
71
  color: var(--ms-text) !important;
72
  font-family: var(--ms-font) !important;
73
  }
 
25
  --ms-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
26
  }
27
 
28
+ /* Gradio 6 mounts the app in a custom-element shadow root. Styling only
29
+ html/body leaves the host transparent in fresh light-mode browsers. */
30
+ :host {
31
+ display: block;
32
+ min-height: 100vh;
33
+ color-scheme: dark;
34
+ background:
35
+ radial-gradient(1000px 620px at 10% -10%, rgba(92, 75, 202, 0.18), transparent 62%),
36
+ radial-gradient(780px 500px at 96% 8%, rgba(53, 103, 175, 0.12), transparent 66%),
37
+ linear-gradient(180deg, #0a0c11 0%, #090b0f 50%, #080a0d 100%);
38
+ }
39
+
40
  html,
41
  body {
42
  min-height: 100%;
 
79
  .gradio-container,
80
  .gradio-container.dark {
81
  min-height: 100vh !important;
82
+ background:
83
+ radial-gradient(1000px 620px at 10% -10%, rgba(92, 75, 202, 0.18), transparent 62%),
84
+ radial-gradient(780px 500px at 96% 8%, rgba(53, 103, 175, 0.12), transparent 66%),
85
+ linear-gradient(180deg, #0a0c11 0%, #090b0f 50%, #080a0d 100%) !important;
86
  color: var(--ms-text) !important;
87
  font-family: var(--ms-font) !important;
88
  }