-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
WIP – Dark mode #1639
WIP – Dark mode #1639
Conversation
squidfunk
commented
Apr 25, 2020
•
edited
edited
Deploy preview for mkdocs-material-preview ready! Built with commit d114778 https://deploy-preview-1639--mkdocs-material-preview.netlify.app |
Yeah, I don't think he's gone through and adjusted all the colors yet. I imagine he'll update the syntax highlighter, footers, and other things. I think this is just the start. |
Still WIP. Don’t worry, footer will be dark as well. |
Will the dark mode have to be configured in config file or users will be able to switch it on and off according to their comfort? |
You can set it via |
So it'll be released with a toggle right? |
I think what he was saying is that the act of toggling is easy, but it will not have a toggle until a good toggle (where we put it) can be worked out. |
Exactly. Sorry if that was not clear enough. A toggle implementation will have to change a single attribute on an element, so it’ll be like 2-3 lines of JS. I’m unsure where to put the toggle, that’s my main concern. |
Can we bind it to a shortcut key too? 😄 In that case we could use it right away as well until toggle |
Another option would be to respect the OS-wide color scheme using |
There won't be a toggle at first. The reason for this is that I'm abstracting dark mode into something more generic called color schemes. This will be another option of the Thus, it's not a binary/boolean option, which makes a toggle impractical. However, later, when some people implemented good toggle solutions, which allow for flexible configuration and switching of schemes, I'm happy to integrate it. This also means no shortcut key. However, the reactive architecture allows for easy extension, so adding it yourself is super simple. Regarding |
I think we have a good candidate, which should be quite ready for release now. The dark mode color scheme is called mkdocs-material/src/assets/stylesheets/base/_colors.scss Lines 64 to 73 in 7a12b5e
Thus, admonitions now have a slightly lighter background color for the Note, that there will always be color combinations that' don't work right out of the box, like for example the |
So does the toggle example you have only work (persistently) because you have instant enabled? |
No, it’s not related to instant loading at all, so no need to enable it. |
So if you switch to a different page with no instant, it'll remember whether you've toggled between light or dark? Forgive my ignorance. |
No, that's up to the author to implement. I may have not read "persistently" in your comment, it can currently only be set from I thought you meant whether the example as such works only with instant loading, and that's not the case. However, with instant loading, it will be persistent until the next full reload. |
Cool, I don't need switching, but I was curious. Thanks! |
@squidfunk I wanted to try the new dark mode since I was awaiting it for weeks, but I can't get it to show.
site_name: My Docs
theme:
name: 'material'
palette:
scheme: slate Starting in a VM with: I tried clearing browser cache and a different browser, Windows System Theme is dark. What did I do wrong? |
I've had the same issue; specifying the primary and/or the accent color fixed it.
|
You may create an issue for that, that’s not intended. |
Thank you @hSaria that fixed it. Are you going to create the issue? |
Sure, I'll create one |
thank ❤️ |