Skip to content

darkMode: 'class' doesn't appear to be honored by daisyUI #640

Closed Answered by saadeghi
longrunningprocess asked this question in Q&A
Discussion options

You must be logged in to vote

This is a different approach.

Tailwind's dark mode needs dark: prefix and when your OS is using the dark mode (or you use class option and the add the dark class to HTML tag) all the class names with dark: prefix gets activated.

daisyUI is using another approach:
Your class names are the same. You don't need dark: prefix in all your elements and you don't need to set light / dark colors for all elements manually.
You use one of these color names instead. This colors get their values from CSS variables.
This way we can have more than 2 themes or we can change a color in the entire app by change one variable value. This wouldn't be possible with the way Tailwind CSS darkmode config suggests.

Replies: 8 comments 11 replies

Comment options

You must be logged in to vote
4 replies
@longrunningprocess
Comment options

@CodeSnooker
Comment options

@saadeghi
Comment options

@CodeSnooker
Comment options

Answer selected by saadeghi
Comment options

You must be logged in to vote
1 reply
@wuarmin
Comment options

Comment options

You must be logged in to vote
1 reply
@saadeghi
Comment options

Comment options

You must be logged in to vote
1 reply
@qqpann
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@saadeghi
Comment options

Comment options

You must be logged in to vote
3 replies
@saadeghi
Comment options

@adnan-smlatic
Comment options

@saadeghi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet