Skip to content

Dark mode using semantic colors #10274

Answered by adamwathan
nareshbhatia asked this question in Help
Discussion options

You must be logged in to vote

I would define all of my colors as CSS variables and use a parent selector just to change the values of the variables, no need to create tons of custom classes:

https://tailwindcss.com/docs/customizing-colors#using-css-variables

This demo is several versions behind so some things are out of date but should communicate the idea clearly at least:

https://github.com/adamwathan/theming-tailwind-demo

Personally I think doing dark mode this way is seductive but not as practical as you expect. Tons of situations where you end up swapping the same color in light mode for two different colors in dark mode depending on how it’s used, and then you need to come up with different names for those two c…

Replies: 2 comments 6 replies

Comment options

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

Comment options

You must be logged in to vote
5 replies
@nareshbhatia
Comment options

@nareshbhatia
Comment options

@nareshbhatia
Comment options

@adamwathan
Comment options

@nareshbhatia
Comment options

Answer selected by nareshbhatia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants