I'm using Tailwind CSS in my ASP.NET MVC project but the dark mode stops working properly when I install Flowbite. The expected behavior is for the color mode (light or dark) to be selected automatically when I switch my OS color mode. It does work like that when I'm using only Tailwind, but when I install Flowbite for some reason it stops working. I'm able to toggle manually for light and dark mode, but I can't make the automatic toggle based on system preferences.
I installed both Tailwind and Flowbite with npm, and in the case of Flowbite, I've manually put the flowbite.min.js
inside the wwwroot/lib
folder because I couldn't make it work through the node_modules
folder.
This is what I have in the tailwind.config.js
:
module.exports = {
content: [
'./Pages/**/*.cshtml',
'./Views/**/*.cshtml',
'./node_modules/flowbite/**/*.js'
],
theme: {
extend: {},
},
plugins: [
require('flowbite/plugin')
],
}
And this is what I have in the package.json
:
{
"name": "MyProject",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"css:build": "npx tailwindcss -i ./wwwroot/css/site.css -o ./wwwroot/css/styles.css --minify"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"tailwindcss": "^3.3.3"
},
"dependencies": {
"flowbite": "^1.8.1"
}
}
I've already tried adding to the tailwind.config.js both darkMode: 'class'
and darkMode: 'media'
and it didn't work. Both of these configs apparently did nothing. And I've also tried uninstalling and reinstalling Flowbite.