Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Tailwind dark mode (dark:hidden) won't hide image or div that contains image. #4238

Closed
sklawik opened this issue May 4, 2021 · 2 comments

Comments

@sklawik
Copy link

sklawik commented May 4, 2021

What version of Tailwind CSS are you using?

v2.0.4

What build tool (or framework if it abstracts the build tool) are you using?

Create React App

What version of Node.js are you using?

v14.16.0

What browser are you using?

Firefox 88.0 (64-bit)

What operating system are you using?

Linux manjaro 5.11.16-2-MANJARO #1 SMP PREEMPT Thu Apr 22 09:53:11 UTC 2021 x86_64 GNU/Linux

Reproduction repository

https://github.com/Hy4e/tailwindcss-bug

Describe your issue

The dark: prefix only works on bg-color, but will not hide div that contains <img/> tag or image itself.
The div will be hidden if it doesn't contain an img tag, or if the div is not the img tag.

@adamwathan
Copy link
Member

Hey! You need to enable the dark variant for the display plugin, it's not enabled for all plugins by default.

https://tailwindcss.com/docs/dark-mode#enabling-for-other-utilities

@sklawik
Copy link
Author

sklawik commented May 4, 2021

Thank you Adam, that's very kind of you.
For readers, here is ready answer to copy-paste to your project so that the problem is fixed.

tailwind.config.js

module.exports = {
  purge: [],
  darkMode: 'class', // or 'media' or 'class'
  theme: {
    extend: {},
  },
  variants: {
    extend: {
      display: ['dark']
    },
  },
  plugins: [],
}

sklawik pushed a commit to sklawik/tailwindcss-bug that referenced this issue May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants