Skip to content

Dark mode on printers #12628

Dec 20, 2023 · 3 comments · 4 replies
Discussion options

You must be logged in to vote

To get your desired output, you can update your addVariant to

addVariant('dark', '@media not print { .dark & }')

This will output css of

@media not print {
  .dark .dark\:border-green-500{
    --tw-border-opacity: 1;
    border-color: rgb(34 197 94 / var(--tw-border-opacity))
  
  /* ... */
}

Additionally, using darkMode: null, instead of darkMode: 'false', will resolve the ts error.

Example: https://play.tailwindcss.com/ARHjiqGpf5?file=config


If you want to have the same css output as v3.4.0 of tailwind, but within the @media not print {...}, you could do

addVariant('dark', '@media not print { :is(:where(.dark) &) }')

This will output css of

@media not print {
  :is(:where(.dark) .dark\…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@dario-baumberger
Comment options

Answer selected by dario-baumberger
Comment options

You must be logged in to vote
2 replies
@dario-baumberger
Comment options

@justingolden21
Comment options

Comment options

You must be logged in to vote
1 reply
@alexwass-lr
Comment options

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