DEV Community

Discussion on: A UseDarkMode react hook for everyone!

Collapse
 
willholmes profile image
Will Holmes

I'm not sure I follow. So above you'll see how I demonstrate the usage of the dark class. But this hook allows you to get the exact value that the dark class will use, just in your react code as well.

Collapse
 
kamil7x profile image
Kamil Trusiak

You can change tailwind config to darkMode: 'class' and then you can use <body class="dark"> to set dark mode regardless of user's prefers-color-scheme value.

Here you have an example play.tailwindcss.com/nQueSOesIA

In this case your hook might report incorrect value.