auliaguss
auliaguss

Reputation: 25

Tailwind Config

please don't roast me.

I tried to enable dark mode in tailwind. The documentation said that I need to set it in my config.

so here is what I do

npm install tailwindcss@latest postcss@latest autoprefixer@latest

then I make the config file

npx tailwindcss init

And put this code in it

module.exports = {
  purge: [],
  presets: [],
  darkMode: "media", // or 'media' or 'class'
  ....
  ....
}

the dark mode is still not enabled, what should I do?

Upvotes: 1

Views: 305

Answers (1)

kirillman
kirillman

Reputation: 79

Have you tried this?

// tailwind.config.js
module.exports = {
  darkMode: 'class',
}

and HTML

<!-- Dark mode not enabled -->
<html>
<body>
  <!-- Will be white -->
  <div class="bg-white dark:bg-black">
    <!-- ... -->
  </div>
</body>
</html>

<!-- Dark mode enabled -->
<html class="dark">
<body>
  <!-- Will be black -->
  <div class="bg-white dark:bg-black">
    <!-- ... -->
  </div>
</body>
</html>

also try to rebuild your project

Upvotes: 1

Related Questions