How to keep dark mode for the Knowledge base site by default?
  • 01 Jul 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

How to keep dark mode for the Knowledge base site by default?

  • Dark
    Light
  • PDF

Users use the Light/Dark option at the top of the article to change the theme. By default, all articles would be in Light mode. If you want to enable the Dark by default, you can use the below solution.

Solution

  1. Go to SettingsKnowledge base siteCustom CSS & JavaScriptCustom JavaScript
  2. Paste the below JavaScript in the window
$(document).ready(function() {

setTimeout(function() { document.getElementById('darkTheme').click(); }, 100); 
});

  1. Click Save
  2. Now, all the articles on your site appear in dark mode by default. However, the user can switch to light mode with the Light option at the top of the article
  3. If you want the user to view only in dark mode, you can disable the theme option in Article settings.
    1. Go to SettingsKnowledge base siteArticle settings
    2. Under Article header, you can find the 'Show theme options' toggle
    3. Toggle it to Off

Was this article helpful?