DEV Community

Cover image for A Simple Light/Dark Theme Toggle - My First NPM Package
JJB9922
JJB9922

Posted on • Updated on

A Simple Light/Dark Theme Toggle - My First NPM Package

To dodge the debate around dark vs light theme, I always put a toggle somewhere on my websites.

The first time I did this, I couldn't find something pre-made that did exactly what I was envisioning - so I made it myself!

It's built to integrate seamlessly with Tailwind and the 'dark' tag:

bg-white dark:bg-black

To keep things simple, I've also used icons instead of text - the light mode toggle is a sun, the dark mode a moon.

Light Mode

Dark Mode

If you'd like to have a play with it, or use it in your own projects, please feel free to do so!

https://github.com/JJB9922/Tailwind-Easy-Theme-Switcher
https://www.npmjs.com/package/tailwind-easy-theme-switcher

Top comments (0)