Setting dark mode by default

Any recommendation on setting the dark mode by default?
I attempted:

  Invoke-UDJavaScript -JavaScript '  sessionStorage.setItem("theme", "dark");function sd() {}'

Which does seem to set dark mode once you refresh the page. Is there a way to do this without a page refresh?

There isn’t a great way to do this right now. We’re adding a new parameter in 1.5 to support this.


@CaelFrost Thanks for the command, I didn’t knew about it.
This got me looking.

Here’s a relatively simple way to do it while waiting for 1.5.
It will require you to edit the index.html file of the relevant Framework.

(Implied Windows default MSI installation. For other OS / types, you’ll have to transpose the directories)

  1. Navigate to : C:\ProgramData\PowerShellUniversal\Dashboard\Frameworks\UniversalDashboard
  2. Go in the framework you are using (For me, I use the latest, which is 3.1.2 on my machine)
  3. Open the index.html with your text editor.
  4. Add the following Javascript script block before the other one present. (#1)
<script type="text/javascript">
  var theme = sessionStorage.getItem("theme");
  if (theme ==null) {
 	sessionStorage.setItem("theme", "dark");

This will result in the dark theme being selected by default and loading with the page if the theme is not set.

Bonus : If you edit the body BG color and set it to the #303030 value, when you refresh the page, instead of having the short white flash of doom, the background of the unloaded page will be the same as the dark theme background.