dark-mode-code

Example in react:


Keywords
nextjs, next, react, dark, mode, code, theme, css, style
Install
npm install dark-mode-code@1.0.1

Documentation

dark-mode-code

Example in react:

const darkModeCode = require('dark-mode-code')

//...
  <script dangerouslySetInnerHTML={{ __html: darkModeCode }} />
//...

Features

  • Automatically set <body class="dark"> if the client OS is in dark mode.
  • Automatically update the former class when the client changes the mode when using the website.
  • Expose a method to manually toggle the theme: window.__toggleDarkMode()

Author

me
Pablo Varela