-
Notifications
You must be signed in to change notification settings - Fork 317
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
Dark mode toggle #458
Comments
the default state should be derived from the system theme via media query like in the furo theme:
cc @bollwyvl |
@flying-sheep check out the PR that is implementing this here: #540 I think that one is getting close, reviews / suggestions are welcome! |
ah neat! #540 is definitely the way to go, very comprehensive. |
@choldgraf do you thing this could be closed now that #540 has been merged or is there still work to do ? |
Indeed, awesome PR (and patience with us) @12rambau. Thank you very much!! |
Thank you all for implementing this feature + providing this great theme. How can I set the default value of this toggle to light mode? We have some plots/logos in our documentation that look better in light mode. |
hmmm I seem to remember us discussing this but I don't remember the conclusion. @12rambau do you remember? |
@freddyaboulton to force the theme you can follow the instruction from the documentation: (https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/configuring.html#configure-default-mode) and set the default theme in the html_context = {
# ...
"default_mode": "light"
} To help you tuning your documentation, there also an entire section about dark mode tricks: |
Hi @choldgraf, how can I add the switch to my doc page? By default, it is using the system setting but I want to add the switch. |
@deepaksirohiwal https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/light-dark.html#configure-default-theme-mode By default the light/dark mode switcher appears in the header bar among the "navbar end items":
Make sure in your html_theme_options = {
# various other entries...
"navbar_end": ["theme-switcher", "navbar-icon-links"],
# ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ this is the crucial bit
} |
Thanks a lot @drammock ! |
@drammock Are you aware of any way to completely disable dark mode (i.e., only allow light mode)? Currently, I am using:
but this doesn't disable dark mode. |
@seanlaw, you cannot really disable it but you can make it unreachable by removing the theme switcher from the header navbar: # conf.py
html_theme_options = {
"navbar_end": ["navbar-icon-links"],
} |
Why would you want to reduce accessibility for your site? |
some sites are using lots of images and third party libs that are not (yet) supporting the dark theme. In order to avoid breaking all their display, they prevent the switch. |
I'd like to disable dark mode completely too. The reason is that originally I created a doc for a light theme. At some point I realised that I also need to tune the doc so it could suit dark theme as well. And currently I have no resources for it. So it would be easier to me to disable it everywhere. |
As an alternative that doesn’t compromise accessibility, you could consider adding a white background or |
@flying-sheep the white background is already automatically added to any all image:
|
Ah, but doesn’t that mean there’s no actual problem? |
for some specific extensions the rendering is not yet very satisfying (jupyterlite, graphviz... etc) so if you perfectly tuned everything for the light one, it's easier to drop the dark one altogether. |
Description
We should implement the ability to toggle between a "dark mode" that makes the background dark and the text light colored.
Benefit
This is an accessibility feature and is also more generally just something that many people find useful to help with readability.
Implementation
We should be able to do this by controlling CSS variables. @bollwyvl even has a nice PR implementation (not quite finished) here: #273
The text was updated successfully, but these errors were encountered: