I would like to do a light mode only modification of a style.
Unfortunately, it doesn't seem like light: exists.
I know that the default approach is to style the light styles and then override in dark mode.
However, my styles come from a library, so in order to achieve the override I want, I'd have to read the source code of the styling library, and then manually set the dark: value to what it was. Something like light: would make the code much cleaner.
Is there anything like it?
I tried Google, looking for SO and the Tailwind docs, but couldn't find anything like it.
I also couldn't find an "inversion" modifier (e.g. non:dark:).
I played a bit with it and was able to add a
light:variant by looking at this repoThe tailwind.config looks like this:
And then, in the HTML I am able to use
dark:andlight:modifiers like here:Here is a Play Tailwind where you can see it in action
If the library you use relies on a class on the
htmltag for switching between light and dark, according to the same repo, you may use the config to look for that particular class name instead:This will generate CSS like:
I hope that works for you. I never did this in a large scale app, and I am not sure what the limitations would be for this solution, but it seems to be working on this simple example.