Better support for printing from dark mode
See original GitHub issueI checked that…
- … the documentation does not mention anything about my idea
- … to my best knowledge, my idea wouldn’t break something for other users
- … there are no open or closed issues that are related to my idea
Description
When using dark mode, printing a page results in barely readable text:

instead, when printing, mkdocs-material could temporarily switch to light mode, and then back.
Use Cases
well, printing obviously.
Screenshots / Mockups
Here is some javascript I adapted from https://stackoverflow.com/a/11060206/5525118 to make it work for mkdocs-material
function change_material_theme(to="default") {
body = document.getElementsByTagName('body')[0];
var current_color_theme = body.getAttribute('data-md-color-scheme')
var beforePrint = function() {
console.log('Functionality to run before printing.');
body.setAttribute("data-md-color-scheme", to);
};
var afterPrint = function() {
console.log('Functionality to run after printing');
body.setAttribute("data-md-color-scheme", current_color_theme);
};
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
mediaQueryList.addListener(function(mql) {
if (mql.matches) {
beforePrint();
} else {
afterPrint();
}
});
}
window.onbeforeprint = beforePrint;
window.onafterprint = afterPrint;
}
And here’s a GIF with the script in action:

Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
dark mode printer output | Apple Developer Forums
I want to print an NSView to the printer while in dark mode. For an NSTextField, I get a white background and white...
Read more >Your Eyes Will Thank You if You Try This Microsoft Word Dark ...
To do this, click on File and Options. Go to the Display tab and look for the Printing Options area.
Read more >Print in Dark Mode in OSX Mojave - Agenda Community
Just to add, Dark mode, High Sierra - exported PDF or printinbg a note, the font is grey. Switching to light mode as...
Read more >Printing problem with Chrome Dark Mode flag enabled.
When I use the Chrome dark mode flag, anything I print in Chrome is way too light to read. This also happens using...
Read more >How to turn your CURA into dark theme - YouTube
3D Printing Doctor ... This video shows how to swap to dark cura! ❤️ Don't forget to follow your @3dprintingdoctor for more.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I can confirm that wrapping the theme definitions in
@media not printworks fine, also with custom color schemes.Maybe that should also be documented in the Custom Color Schemes section. Something like “If your custom colors don’t look good when printed, wrap the definitions in …”
The only thing where this does not work is when using multiple color palettes through Insiders with bright primary and accent colors, e.g.
slatewithyellowas a primary. Theslatetheme would be reset, but the primary color wouldn’t. We need a solution for this, too.