We use the class
strategy from Tailwind CSS to support dark mode toggling. See the Tailwind CSS documentation for more information.
How you add the dark
class to the html
element is up to you. In this guide, we will take a look at enabling dark mode toggling with mode-watcher.
Usage
Install mode-watcher
Start by installing mode-watcher
:
Add the ModeWatcher component
Import the ModeWatcher
component and use it in your root layout:
Add a mode toggle
Place a mode toggle on your site to toggle between light and dark mode.
Light switch