dark-mode-code

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i dark-mode-code

Weekly Downloads

9

Version

1.0.1

License

none

Unpacked Size

1.6 kB

Total Files

3

Last publish

Collaborators

  • pablopunk