Skip to content
On this page

Dark mode

The dark mode is a system that allows you to change the color of the interface to a darker color. This is a feature that is becoming more and more popular in applications and websites. It is a feature that is very useful for users who spend a lot of time in front of the screen, as it reduces the strain on the eyes.

Usage

You can create a dark mode by adding a dark class to the html element.

ts
// switch to dark mode
document.documentElement.classList.add('dark')

// switch to light mode
document.documentElement.classList.remove('dark')

And the html is like this:

html
<html class="dark">
  <body></body>
</html>

© 2023 ziyiLike