Replies: 8 comments 9 replies
-
In terms of CSS, yes, there is a media query for print: @media print {
/* ... */
} More here: https://benfrain.com/create-print-styles-using-css3-media-queries. You can actually tell Tailwind this is something you want: https://tailwindcss.com/docs/breakpoints/#styling-for-print. The example from the docs: module.exports = {
theme: {
extend: {
screens: {
'print': {'raw': 'print'},
// => @media print { ... }
}
}
}
} <div class="text-gray-700 print:text-black">
<!-- ... -->
</div> Essentially you’re just compiling another screen size you can use as a prefix. Note that this falls under the |
Beta Was this translation helpful? Give feedback.
-
Can |
Beta Was this translation helpful? Give feedback.
-
I guess this is not a big thing to set up unlike having access to a good cross-section of fonts, but still having a default way would be desirable. |
Beta Was this translation helpful? Give feedback.
-
An extra screen does make the CDN build a lot larger. As every utility that has the |
Beta Was this translation helpful? Give feedback.
-
I found that it could be set like this ## tailwind.config.js
module.exports = {
theme: {
extend: {
// 要设置 sm md lg等选择器在打印中生效
screens: {
'lg': {'raw': 'print, (min-width: 1024px)'},
// 'lg': {'min': '1024px', 'max': '1279px', 'raw': 'print'}, // error
// => @media print { ... }
}
},
},
} |
Beta Was this translation helpful? Give feedback.
-
This still works in version 3.1.8 // tailwind.config.js
module.exports = {
theme: {
extend: {
screens: {
'print': {'raw': 'print'},
// => @media print { ... }
}
}
}
} Use it in markup like so: <!-- removes top menu bar div from printed document -->
<div id="top-menu-bar" class="print:hidden">
<a href="/">Home</a>
<a href="/projects">Projects</a>
<a href="/blog">Blog</a>
</div> But I am wondering why it was removed from the v3 docs. v2 docs for reference: https://v2.tailwindcss.com/docs/breakpoints#styling-for-print |
Beta Was this translation helpful? Give feedback.
-
I'm wondering if there is some way to disable dark mode when printing using this? I want my printed pages to always be in light mode |
Beta Was this translation helpful? Give feedback.
-
How to put xl+ desktop screen into print version for vertical A4 page? |
Beta Was this translation helpful? Give feedback.
-
Is it possible to add better support for printing, especially styling and also elements to be shown differently in print and on-screen? Some elements like adds you do not need to show on print and can be shown only on the screen while others may only be on the print like TOC.
Beta Was this translation helpful? Give feedback.
All reactions