If you need to a (print stylesheet) for your website and you use Tailwind you can customize the to include custom media queries.

Use Print stylesheets for printers and PDFs

YouTube video thumbnail

The appearance of a website often differs when printed or saved as a PDF. For that reason it is useful to define CSS styles that only apply to printers or PDFs (or devices that satisfy the media query).

Tailwind config extend media queries

Extend the standard tailwind config in a file itesting-email-with-cypressn your project root.

This means we can use classes such as to apply a margin to an element only for print styles.

Using custom classes

Here is an example using React. Notice the class names that have a prefix.

Results

This is an example of how flexible Tailwind CSS can be. It lets you configure print styles using custom media queries so that you can use all the standard tailwind classes with a prefix to apply the rule's styles only when a print media query is satisfied.

In the screenshot below we can see a website with a print dialog above it showing the print and screen styles together. Notice the difference that was achieved using the tailwind css print media queries: