Skip to content
Discussion options

You must be logged in to vote

Hi @Daremonic! To make dark mode the default, replace the script in your Navbar and/or NavbarMegaMenu components with this code. It defaults to dark mode if no theme preference is stored in localStorage:

<script is:inline>
  const HSThemeAppearance = {
    init() {
      let theme = localStorage.getItem("hs_theme");

      if (theme === null) {
        theme = "dark";
        localStorage.setItem("hs_theme", theme);
      }
      this.setAppearance(theme);
    },
    _resetStylesOnLoad() {
      const $resetStyles = document.createElement("style");
      $resetStyles.innerText = `*{transition: unset !important;}`;
      $resetStyles.setAttribute("data-hs-appearance-onload-styles", "");

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tekorakle
Comment options

Answer selected by tekorakle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants