This is a simple CSS file that you can add to your Netlify CMS's HTML file.
It automatically toggles your Netlify cms to dark mode if your system is also set to dark mode.
You can view the demo site here.
This is mainly for people who install the Netlify CMS with javascript from the CDN. Since there are more limitations with customization.
But you can also use this with the npm installation method. However, it's better to write a separate package.
Pull dark.css
from a public cdn, so it will keep up-to-date. https://cdn.jsdelivr.net/gh/Nats-ji/netlify-cms-dark@master/dark.min.css
-
Edit your Netlify CMS's HTML code:
</body> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Nats-ji/netlify-cms-dark-mode@master/dark.min.css"> </html>
This method gives you more flexablity for making customizations.
-
Download dark.css, and copy it to your site.
-
Open your Netlify CMS's HTML file.
-
Link
dark.css
behind the</body>
tag.</body> <link rel="stylesheet" href="./dark.css"> </html>
You can check the demo HTML source code here.
-
Just edit the css vars in
dark.css
!:root { --body-bg-color: black; }
-
If you want always dark mode instead of following the system's setting. You can remove the following code from
dark.css
:@media (prefers-color-scheme: dark) { }
You are welcome to make a Pull Request to fix any bugs or make any improvements.