tailwindlabs / tailwindcss-forms

A plugin that provides a basic reset for form styles that makes form elements easy to override with utilities.
https://tailwindcss-forms.vercel.app
MIT License
4.24k stars 224 forks source link

Dark mode background overrides text colors on checkboxes when using `class` dark mode variant #74

Open johnathanludwig opened 3 years ago

johnathanludwig commented 3 years ago

What version of @tailwindcss/forms are you using?

0.3.3

What version of Node.js are you using?

14.15.4

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction repository

https://github.com/johnathanludwig/tailwind-forms-dark-mode

Describe your issue

In light mode you can style a checkbox by setting a background color for the base checkbox, and a text color for the checked version of the checkbox.

With dark mode via the class method, the background classes sets both the unchecked and checked color removing the ability to customize.

The styling works properly when using media for dark mode.

Reproduction Steps:

  1. Build tailwind using @tailwindcss/forms and enable dark mode using the class method.
  2. Add checkbox with a dark background color class and dark text color class.
  3. Enable wrap the checkbox in a dark class.
  4. Check the checkbox

Expected Results

The text color should be displayed when the checkbox is checked.

Actual Results

The background color is used for both checked and unchecked checkboxes.

colinbate commented 3 years ago

In the mean time you should be able to get around this by adding this to whichever file you are including tailwind from:

.dark [type="checkbox"]:checked,
.dark [type="radio"]:checked {
  background-color: currentColor;
}
johnathanludwig commented 3 years ago

@colinbate Thank you, that definitely works as a workaround for now!

adamwathan commented 2 years ago

Just some notes for myself, this is because the selector .dark .dark\:bg-gray-600 has a higher specificity than [type="checkbox"]:checked, so it is taking precedence.

I think we need to try and rework some stuff here in general — we should be recommending checked:bg-blue-300 instead of text-blue-300 for this stuff now that every variant is available by default in v3.

Also need to investigate why we are using [type="checkbox"]:checked:hover { .... } out of the box for anything — I'm guessing it's because bg-gray-300 hover:bg-gray-200 was causing the hover style to override the checked style, but maybe there's a better solution to this problem in the v3 era.

Kittease commented 1 year ago

Any update by chance on this issue?

adamwathan commented 1 year ago

Any update by chance on this issue?

Not yet! Going to revisit all the forms stuff in the new year at some point though, think we can do something better than we have now altogether.

kudp02 commented 1 year ago

Just bumped into this issue +1

colinmackinlay commented 9 months ago

Also on date pickers please @adamwathan ! Need to be able to apply style="color-scheme: dark;" when in dark mode so that the icon is reversed and visible