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

Prev Next

Plans supporting the use of custom CSS and JS in knowledge base site

Professional
Business
Enterprise






You can use the Light or Dark option at the top of the article to change the theme.  If you want to enable the Dark by default, you can use the below solution.

NOTE

By default, all articles would be in Light mode.

Solution

  1. Navigate to Settings () > Knowledge base site > Customize site > Custom CSS & JavaScript in the Knowledge base portal.

  2. From the left navigation pane, click on the JavaScript tab and paste the following Javascript snippet:

$(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 turn off the theme option in Article settings.

    a. Navigate to Settings () icon > Knowledge base site > Customize site.

    b. Under the Site theme section, select the Dark only option and click Save at the top.